cloudfront

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package cloudfront provides CloudFront service emulation for kumo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveTrustedKeyGroups

type ActiveTrustedKeyGroups struct {
	Enabled  bool
	Quantity int
}

ActiveTrustedKeyGroups represents active trusted key groups.

type ActiveTrustedKeyGroupsXML

type ActiveTrustedKeyGroupsXML struct {
	Enabled  bool `xml:"Enabled"`
	Quantity int  `xml:"Quantity"`
}

ActiveTrustedKeyGroupsXML represents active trusted key groups in XML.

type ActiveTrustedSigners

type ActiveTrustedSigners struct {
	Enabled  bool
	Quantity int
}

ActiveTrustedSigners represents active trusted signers.

type ActiveTrustedSignersXML

type ActiveTrustedSignersXML struct {
	Enabled  bool `xml:"Enabled"`
	Quantity int  `xml:"Quantity"`
}

ActiveTrustedSignersXML represents active trusted signers in XML.

type Aliases

type Aliases struct {
	Quantity int
	Items    []string
}

Aliases represents CNAMEs for a distribution.

type AliasesXML

type AliasesXML struct {
	Quantity int       `xml:"Quantity"`
	Items    *ItemsXML `xml:"Items,omitempty"`
}

AliasesXML represents aliases in XML format.

type AllowedMethods

type AllowedMethods struct {
	Quantity int
	Items    []string
}

AllowedMethods represents allowed HTTP methods.

type AllowedMethodsXML

type AllowedMethodsXML struct {
	Quantity      int               `xml:"Quantity"`
	Items         []string          `xml:"Items>Method,omitempty"`
	CachedMethods *CachedMethodsXML `xml:"CachedMethods,omitempty"`
}

AllowedMethodsXML represents allowed methods in XML format.

type CacheBehavior

type CacheBehavior struct {
	PathPattern             string
	TargetOriginID          string
	ViewerProtocolPolicy    string
	AllowedMethods          *AllowedMethods
	CachedMethods           *CachedMethods
	ForwardedValues         *ForwardedValues
	MinTTL                  int64
	DefaultTTL              int64
	MaxTTL                  int64
	Compress                bool
	SmoothStreaming         bool
	CachePolicyID           string
	OriginRequestPolicyID   string
	ResponseHeadersPolicyID string
	TrustedSigners          *TrustedSigners
	TrustedKeyGroups        *TrustedKeyGroups
	FieldLevelEncryptionID  string
	RealtimeLogConfigArn    string
}

CacheBehavior represents a cache behavior.

type CacheBehaviors

type CacheBehaviors struct {
	Quantity int
	Items    []CacheBehavior
}

CacheBehaviors represents cache behaviors.

type CacheBehaviorsXML

type CacheBehaviorsXML struct {
	Quantity int `xml:"Quantity"`
}

CacheBehaviorsXML represents cache behaviors in XML format.

type CachedMethods

type CachedMethods struct {
	Quantity int
	Items    []string
}

CachedMethods represents cached HTTP methods.

type CachedMethodsXML

type CachedMethodsXML struct {
	Quantity int      `xml:"Quantity"`
	Items    []string `xml:"Items>Method,omitempty"`
}

CachedMethodsXML represents cached methods in XML format.

type CookieNames

type CookieNames struct {
	Quantity int
	Items    []string
}

CookieNames represents a list of cookie names.

type CookiePreference

type CookiePreference struct {
	Forward          string
	WhitelistedNames *CookieNames
}

CookiePreference represents cookie forwarding preference.

type CookiesXML

type CookiesXML struct {
	Forward string `xml:"Forward"`
}

CookiesXML represents cookies configuration in XML format.

type CreateDistributionRequest

type CreateDistributionRequest struct {
	XMLName              xml.Name                 `xml:"DistributionConfig"`
	CallerReference      string                   `xml:"CallerReference"`
	Aliases              *AliasesXML              `xml:"Aliases,omitempty"`
	DefaultRootObject    string                   `xml:"DefaultRootObject,omitempty"`
	Origins              *OriginsXML              `xml:"Origins"`
	DefaultCacheBehavior *DefaultCacheBehaviorXML `xml:"DefaultCacheBehavior"`
	CacheBehaviors       *CacheBehaviorsXML       `xml:"CacheBehaviors,omitempty"`
	Comment              string                   `xml:"Comment"`
	Enabled              bool                     `xml:"Enabled"`
	PriceClass           string                   `xml:"PriceClass,omitempty"`
	ViewerCertificate    *ViewerCertificateXML    `xml:"ViewerCertificate,omitempty"`
	HTTPVersion          string                   `xml:"HttpVersion,omitempty"`
	IsIPV6Enabled        bool                     `xml:"IsIPV6Enabled,omitempty"`
}

CreateDistributionRequest is the request for CreateDistribution.

type CreateDistributionResult

type CreateDistributionResult struct {
	XMLName      xml.Name     `xml:"Distribution"`
	Xmlns        string       `xml:"xmlns,attr"`
	Distribution Distribution `xml:",innerxml"`
}

CreateDistributionResult is the response for CreateDistribution.

type CreateInvalidationRequest

type CreateInvalidationRequest struct {
	XMLName         xml.Name  `xml:"InvalidationBatch"`
	Paths           *PathsXML `xml:"Paths"`
	CallerReference string    `xml:"CallerReference"`
}

CreateInvalidationRequest is the request for CreateInvalidation.

type CustomErrorResponsesXML

type CustomErrorResponsesXML struct {
	Quantity int `xml:"Quantity"`
}

CustomErrorResponsesXML represents custom error responses in XML format.

type CustomOriginConfig

type CustomOriginConfig struct {
	HTTPPort               int
	HTTPSPort              int
	OriginProtocolPolicy   string
	OriginSSLProtocols     *OriginSSLProtocols
	OriginReadTimeout      int
	OriginKeepaliveTimeout int
}

CustomOriginConfig represents custom origin configuration.

type CustomOriginConfigXML

type CustomOriginConfigXML struct {
	HTTPPort               int                    `xml:"HTTPPort"`
	HTTPSPort              int                    `xml:"HTTPSPort"`
	OriginProtocolPolicy   string                 `xml:"OriginProtocolPolicy"`
	OriginSSLProtocols     *OriginSSLProtocolsXML `xml:"OriginSslProtocols,omitempty"`
	OriginReadTimeout      int                    `xml:"OriginReadTimeout,omitempty"`
	OriginKeepaliveTimeout int                    `xml:"OriginKeepaliveTimeout,omitempty"`
}

CustomOriginConfigXML represents custom origin config in XML format.

type DefaultCacheBehavior

type DefaultCacheBehavior struct {
	TargetOriginID          string
	ViewerProtocolPolicy    string
	AllowedMethods          *AllowedMethods
	CachedMethods           *CachedMethods
	ForwardedValues         *ForwardedValues
	MinTTL                  int64
	DefaultTTL              int64
	MaxTTL                  int64
	Compress                bool
	SmoothStreaming         bool
	CachePolicyID           string
	OriginRequestPolicyID   string
	ResponseHeadersPolicyID string
	TrustedSigners          *TrustedSigners
	TrustedKeyGroups        *TrustedKeyGroups
	FieldLevelEncryptionID  string
	RealtimeLogConfigArn    string
}

DefaultCacheBehavior represents the default cache behavior.

type DefaultCacheBehaviorXML

type DefaultCacheBehaviorXML struct {
	TargetOriginID       string               `xml:"TargetOriginId"`
	ViewerProtocolPolicy string               `xml:"ViewerProtocolPolicy"`
	AllowedMethods       *AllowedMethodsXML   `xml:"AllowedMethods,omitempty"`
	ForwardedValues      *ForwardedValuesXML  `xml:"ForwardedValues,omitempty"`
	MinTTL               int64                `xml:"MinTTL,omitempty"`
	DefaultTTL           int64                `xml:"DefaultTTL,omitempty"`
	MaxTTL               int64                `xml:"MaxTTL,omitempty"`
	Compress             bool                 `xml:"Compress,omitempty"`
	CachePolicyID        string               `xml:"CachePolicyId,omitempty"`
	TrustedSigners       *TrustedSignersXML   `xml:"TrustedSigners,omitempty"`
	TrustedKeyGroups     *TrustedKeyGroupsXML `xml:"TrustedKeyGroups,omitempty"`
}

DefaultCacheBehaviorXML represents default cache behavior in XML format.

type Distribution

type Distribution struct {
	ID                     string
	ARN                    string
	Status                 string
	LastModifiedTime       time.Time
	DomainName             string
	ETag                   string
	DistributionConfig     *DistributionConfig
	ActiveTrustedSigners   *ActiveTrustedSigners
	ActiveTrustedKeyGroups *ActiveTrustedKeyGroups
}

Distribution represents a CloudFront distribution.

type DistributionConfig

type DistributionConfig struct {
	CallerReference      string
	Origins              *Origins
	DefaultCacheBehavior *DefaultCacheBehavior
	Comment              string
	Enabled              bool
	PriceClass           string
	Aliases              *Aliases
	DefaultRootObject    string
	CacheBehaviors       *CacheBehaviors
	ViewerCertificate    *ViewerCertificate
	HTTPVersion          string
	IsIPV6Enabled        bool
}

DistributionConfig represents CloudFront distribution configuration.

type DistributionConfigXML

type DistributionConfigXML struct {
	CallerReference      string                   `xml:"CallerReference"`
	Aliases              *AliasesXML              `xml:"Aliases,omitempty"`
	DefaultRootObject    string                   `xml:"DefaultRootObject,omitempty"`
	Origins              *OriginsXML              `xml:"Origins"`
	DefaultCacheBehavior *DefaultCacheBehaviorXML `xml:"DefaultCacheBehavior"`
	CacheBehaviors       *CacheBehaviorsXML       `xml:"CacheBehaviors,omitempty"`
	Comment              string                   `xml:"Comment"`
	Enabled              bool                     `xml:"Enabled"`
	PriceClass           string                   `xml:"PriceClass,omitempty"`
	ViewerCertificate    *ViewerCertificateXML    `xml:"ViewerCertificate,omitempty"`
	HTTPVersion          string                   `xml:"HttpVersion,omitempty"`
	IsIPV6Enabled        bool                     `xml:"IsIPV6Enabled,omitempty"`
}

DistributionConfigXML represents distribution config in XML format.

type DistributionListXML

type DistributionListXML struct {
	XMLName     xml.Name                 `xml:"DistributionList"`
	Xmlns       string                   `xml:"xmlns,attr"`
	Marker      string                   `xml:"Marker"`
	MaxItems    int                      `xml:"MaxItems"`
	IsTruncated bool                     `xml:"IsTruncated"`
	Quantity    int                      `xml:"Quantity"`
	Items       *DistributionSummaryList `xml:"Items,omitempty"`
	NextMarker  string                   `xml:"NextMarker,omitempty"`
}

DistributionListXML represents a list of distributions in XML format.

type DistributionSummaryList

type DistributionSummaryList struct {
	DistributionSummary []DistributionSummaryXML `xml:"DistributionSummary"`
}

DistributionSummaryList is a list of distribution summaries.

type DistributionSummaryXML

type DistributionSummaryXML struct {
	ID                   string                   `xml:"Id"`
	ARN                  string                   `xml:"ARN"`
	Status               string                   `xml:"Status"`
	LastModifiedTime     string                   `xml:"LastModifiedTime"`
	DomainName           string                   `xml:"DomainName"`
	Aliases              *AliasesXML              `xml:"Aliases"`
	Origins              *OriginsXML              `xml:"Origins"`
	DefaultCacheBehavior *DefaultCacheBehaviorXML `xml:"DefaultCacheBehavior"`
	CacheBehaviors       *CacheBehaviorsXML       `xml:"CacheBehaviors"`
	CustomErrorResponses *CustomErrorResponsesXML `xml:"CustomErrorResponses"`
	Comment              string                   `xml:"Comment"`
	PriceClass           string                   `xml:"PriceClass"`
	Enabled              bool                     `xml:"Enabled"`
	ViewerCertificate    *ViewerCertificateXML    `xml:"ViewerCertificate"`
	Restrictions         *RestrictionsXML         `xml:"Restrictions"`
	WebACLId             string                   `xml:"WebACLId"`
	HTTPVersion          string                   `xml:"HttpVersion"`
	IsIPV6Enabled        bool                     `xml:"IsIPV6Enabled"`
	Staging              bool                     `xml:"Staging"`
}

DistributionSummaryXML represents a distribution summary in XML format.

type DistributionXML

type DistributionXML struct {
	XMLName                xml.Name                   `xml:"Distribution"`
	ID                     string                     `xml:"Id"`
	ARN                    string                     `xml:"ARN"`
	Status                 string                     `xml:"Status"`
	LastModifiedTime       string                     `xml:"LastModifiedTime"`
	DomainName             string                     `xml:"DomainName"`
	ActiveTrustedSigners   *ActiveTrustedSignersXML   `xml:"ActiveTrustedSigners"`
	ActiveTrustedKeyGroups *ActiveTrustedKeyGroupsXML `xml:"ActiveTrustedKeyGroups"`
	DistributionConfig     *DistributionConfigXML     `xml:"DistributionConfig"`
}

DistributionXML represents a distribution in XML format.

type Error

type Error struct {
	Code    string
	Message string
}

Error represents a CloudFront error.

func (*Error) Error

func (e *Error) Error() string

type ErrorDetail

type ErrorDetail struct {
	Type    string `xml:"Type"`
	Code    string `xml:"Code"`
	Message string `xml:"Message"`
}

ErrorDetail represents the error detail.

type ErrorResponse

type ErrorResponse struct {
	XMLName   xml.Name    `xml:"ErrorResponse"`
	Xmlns     string      `xml:"xmlns,attr"`
	Error     ErrorDetail `xml:"Error"`
	RequestID string      `xml:"RequestId"`
}

ErrorResponse represents a CloudFront error response.

type ForwardedValues

type ForwardedValues struct {
	QueryString          bool
	Cookies              *CookiePreference
	Headers              *Headers
	QueryStringCacheKeys *QueryStringCacheKeys
}

ForwardedValues represents forwarded values configuration.

type ForwardedValuesXML

type ForwardedValuesXML struct {
	QueryString bool        `xml:"QueryString"`
	Cookies     *CookiesXML `xml:"Cookies"`
	Headers     *HeadersXML `xml:"Headers,omitempty"`
}

ForwardedValuesXML represents forwarded values in XML format.

type GeoRestrictionXML

type GeoRestrictionXML struct {
	RestrictionType string   `xml:"RestrictionType"`
	Quantity        int      `xml:"Quantity"`
	Items           []string `xml:"Items>Location,omitempty"`
}

GeoRestrictionXML represents geo restriction in XML format.

type GetDistributionResult

type GetDistributionResult struct {
	XMLName                xml.Name                   `xml:"Distribution"`
	Xmlns                  string                     `xml:"xmlns,attr"`
	ID                     string                     `xml:"Id"`
	ARN                    string                     `xml:"ARN"`
	Status                 string                     `xml:"Status"`
	LastModifiedTime       string                     `xml:"LastModifiedTime"`
	DomainName             string                     `xml:"DomainName"`
	ActiveTrustedSigners   *ActiveTrustedSignersXML   `xml:"ActiveTrustedSigners"`
	ActiveTrustedKeyGroups *ActiveTrustedKeyGroupsXML `xml:"ActiveTrustedKeyGroups"`
	DistributionConfig     *DistributionConfigXML     `xml:"DistributionConfig"`
}

GetDistributionResult is the response for GetDistribution.

type Headers

type Headers struct {
	Quantity int
	Items    []string
}

Headers represents a list of headers.

type HeadersXML

type HeadersXML struct {
	Quantity int      `xml:"Quantity"`
	Items    []string `xml:"Items>Name,omitempty"`
}

HeadersXML represents headers in XML format.

type Invalidation

type Invalidation struct {
	ID                string
	Status            string
	CreateTime        time.Time
	InvalidationBatch *InvalidationBatch
}

Invalidation represents a CloudFront invalidation.

type InvalidationBatch

type InvalidationBatch struct {
	Paths           *Paths
	CallerReference string
}

InvalidationBatch represents an invalidation batch.

type InvalidationBatchXML

type InvalidationBatchXML struct {
	Paths           *PathsXML `xml:"Paths"`
	CallerReference string    `xml:"CallerReference"`
}

InvalidationBatchXML represents an invalidation batch in XML format.

type InvalidationListXML

type InvalidationListXML struct {
	XMLName     xml.Name                 `xml:"InvalidationList"`
	Xmlns       string                   `xml:"xmlns,attr"`
	Marker      string                   `xml:"Marker"`
	MaxItems    int                      `xml:"MaxItems"`
	IsTruncated bool                     `xml:"IsTruncated"`
	Quantity    int                      `xml:"Quantity"`
	Items       *InvalidationSummaryList `xml:"Items,omitempty"`
	NextMarker  string                   `xml:"NextMarker,omitempty"`
}

InvalidationListXML represents a list of invalidations in XML format.

type InvalidationSummaryList

type InvalidationSummaryList struct {
	InvalidationSummary []InvalidationSummaryXML `xml:"InvalidationSummary"`
}

InvalidationSummaryList is a list of invalidation summaries.

type InvalidationSummaryXML

type InvalidationSummaryXML struct {
	ID         string `xml:"Id"`
	CreateTime string `xml:"CreateTime"`
	Status     string `xml:"Status"`
}

InvalidationSummaryXML represents an invalidation summary in XML format.

type InvalidationXML

type InvalidationXML struct {
	XMLName           xml.Name              `xml:"Invalidation"`
	ID                string                `xml:"Id"`
	Status            string                `xml:"Status"`
	CreateTime        string                `xml:"CreateTime"`
	InvalidationBatch *InvalidationBatchXML `xml:"InvalidationBatch"`
}

InvalidationXML represents an invalidation in XML format.

type ItemsXML

type ItemsXML struct {
	Items []string `xml:"CNAME,omitempty"`
}

ItemsXML is a generic items container for XML.

type KeyGroup added in v0.22.0

type KeyGroup struct {
	ID             string
	LastModified   time.Time
	ETag           string
	KeyGroupConfig *KeyGroupConfig
}

KeyGroup groups one or more PublicKey IDs that a Distribution can reference via TrustedKeyGroups.

type KeyGroupConfig added in v0.22.0

type KeyGroupConfig struct {
	Name    string
	Items   []string // PublicKey IDs
	Comment string
}

KeyGroupConfig is the user-supplied configuration of a KeyGroup.

type KeyGroupConfigXML added in v0.22.0

type KeyGroupConfigXML struct {
	XMLName xml.Name `xml:"KeyGroupConfig"`
	Xmlns   string   `xml:"xmlns,attr,omitempty"`
	Name    string   `xml:"Name"`
	Items   []string `xml:"Items>PublicKey"`
	Comment string   `xml:"Comment,omitempty"`
}

KeyGroupConfigXML is the XML view of KeyGroupConfig.

type KeyGroupListXML added in v0.22.0

type KeyGroupListXML struct {
	XMLName  xml.Name             `xml:"KeyGroupList"`
	Xmlns    string               `xml:"xmlns,attr"`
	MaxItems int                  `xml:"MaxItems"`
	Quantity int                  `xml:"Quantity"`
	Items    []KeyGroupSummaryXML `xml:"Items>KeyGroupSummary,omitempty"`
}

KeyGroupListXML is the body of ListKeyGroups.

type KeyGroupResultXML added in v0.22.0

type KeyGroupResultXML struct {
	XMLName        xml.Name           `xml:"KeyGroup"`
	Xmlns          string             `xml:"xmlns,attr"`
	ID             string             `xml:"Id"`
	LastModified   string             `xml:"LastModifiedTime"`
	KeyGroupConfig *KeyGroupConfigXML `xml:"KeyGroupConfig"`
}

KeyGroupResultXML is the XML body of GetKeyGroup / CreateKeyGroup responses.

type KeyGroupSummaryXML added in v0.22.0

type KeyGroupSummaryXML struct {
	KeyGroup KeyGroupResultXML `xml:"KeyGroup"`
}

KeyGroupSummaryXML is one item in KeyGroupList.

type MemoryStorage

type MemoryStorage struct {
	Distributions map[string]*Distribution            `json:"distributions"`
	Invalidations map[string]map[string]*Invalidation `json:"invalidations"` // distributionID -> invalidationID -> Invalidation
	// contains filtered or unexported fields
}

MemoryStorage implements Storage with in-memory data.

func NewMemoryStorage

func NewMemoryStorage(opts ...Option) *MemoryStorage

NewMemoryStorage creates a new memory storage.

func (*MemoryStorage) Close added in v0.6.0

func (s *MemoryStorage) Close() error

Close saves the storage state to disk if persistence is enabled.

func (*MemoryStorage) CreateDistribution

func (s *MemoryStorage) CreateDistribution(_ context.Context, config *CreateDistributionRequest) (*Distribution, error)

CreateDistribution creates a new distribution.

func (*MemoryStorage) CreateInvalidation

func (s *MemoryStorage) CreateInvalidation(_ context.Context, distributionID string, batch *CreateInvalidationRequest) (*Invalidation, error)

CreateInvalidation creates a new invalidation.

func (*MemoryStorage) CreateKeyGroup added in v0.22.0

func (s *MemoryStorage) CreateKeyGroup(_ context.Context, cfg *KeyGroupConfig) (*KeyGroup, error)

CreateKeyGroup adds a new KeyGroup. All referenced PublicKey IDs must exist; otherwise NoSuchPublicKey is returned.

func (*MemoryStorage) CreatePublicKey added in v0.22.0

func (s *MemoryStorage) CreatePublicKey(_ context.Context, cfg *PublicKeyConfig) (*PublicKey, error)

CreatePublicKey adds a new PublicKey. CallerReference dedupes — a duplicate returns 409 (PublicKeyAlreadyExists), matching real CF.

func (*MemoryStorage) DeleteDistribution

func (s *MemoryStorage) DeleteDistribution(_ context.Context, id, etag string) error

DeleteDistribution deletes a distribution.

func (*MemoryStorage) DeleteKeyGroup added in v0.22.0

func (s *MemoryStorage) DeleteKeyGroup(_ context.Context, id string) error

DeleteKeyGroup removes a KeyGroup. Returns ResourceInUse if any Distribution references it via TrustedKeyGroups.

func (*MemoryStorage) DeletePublicKey added in v0.22.0

func (s *MemoryStorage) DeletePublicKey(_ context.Context, id string) error

DeletePublicKey removes a PublicKey. Returns PublicKeyInUse if any KeyGroup still references it — matches real CloudFront's safety net.

func (*MemoryStorage) GetDistribution

func (s *MemoryStorage) GetDistribution(_ context.Context, id string) (*Distribution, error)

GetDistribution retrieves a distribution by ID.

func (*MemoryStorage) GetInvalidation

func (s *MemoryStorage) GetInvalidation(_ context.Context, distributionID, invalidationID string) (*Invalidation, error)

GetInvalidation retrieves an invalidation.

func (*MemoryStorage) GetKeyGroup added in v0.22.0

func (s *MemoryStorage) GetKeyGroup(_ context.Context, id string) (*KeyGroup, error)

GetKeyGroup retrieves a KeyGroup by ID.

func (*MemoryStorage) GetPublicKey added in v0.22.0

func (s *MemoryStorage) GetPublicKey(_ context.Context, id string) (*PublicKey, error)

GetPublicKey retrieves a PublicKey by ID.

func (*MemoryStorage) ListDistributions

func (s *MemoryStorage) ListDistributions(_ context.Context, marker string, maxItems int) ([]*Distribution, string, error)

ListDistributions lists all distributions.

func (*MemoryStorage) ListInvalidations

func (s *MemoryStorage) ListInvalidations(_ context.Context, distributionID, marker string, maxItems int) ([]*Invalidation, string, error)

ListInvalidations lists invalidations for a distribution.

func (*MemoryStorage) ListKeyGroups added in v0.22.0

func (s *MemoryStorage) ListKeyGroups(_ context.Context) []*KeyGroup

ListKeyGroups returns every stored KeyGroup, sorted by ID.

func (*MemoryStorage) ListPublicKeys added in v0.22.0

func (s *MemoryStorage) ListPublicKeys(_ context.Context) []*PublicKey

ListPublicKeys returns every stored PublicKey, sorted by ID for deterministic output. (CloudFront does not paginate this endpoint in practice — at most ~25 keys per account.)

func (*MemoryStorage) MarshalJSON added in v0.6.0

func (s *MemoryStorage) MarshalJSON() ([]byte, error)

MarshalJSON serializes the storage state to JSON.

func (*MemoryStorage) UnmarshalJSON added in v0.6.0

func (s *MemoryStorage) UnmarshalJSON(data []byte) error

UnmarshalJSON restores the storage state from JSON.

func (*MemoryStorage) UpdateDistribution

func (s *MemoryStorage) UpdateDistribution(_ context.Context, id string, config *CreateDistributionRequest, etag string) (*Distribution, error)

UpdateDistribution updates a distribution.

type Option added in v0.6.0

type Option func(*MemoryStorage)

Option is a configuration option for MemoryStorage.

func WithDataDir added in v0.6.0

func WithDataDir(dir string) Option

WithDataDir enables persistent storage in the specified directory.

type Origin

type Origin struct {
	ID                    string
	DomainName            string
	OriginPath            string
	S3OriginConfig        *S3OriginConfig
	CustomOriginConfig    *CustomOriginConfig
	ConnectionAttempts    int
	ConnectionTimeout     int
	OriginAccessControlID string
}

Origin represents a CloudFront origin.

type OriginList

type OriginList struct {
	Origin []OriginXML `xml:"Origin"`
}

OriginList is a list of origins.

type OriginSSLProtocols

type OriginSSLProtocols struct {
	Quantity int
	Items    []string
}

OriginSSLProtocols represents allowed SSL protocols for origin.

type OriginSSLProtocolsXML

type OriginSSLProtocolsXML struct {
	Quantity int      `xml:"Quantity"`
	Items    []string `xml:"Items>SslProtocol,omitempty"`
}

OriginSSLProtocolsXML represents origin SSL protocols in XML format.

type OriginXML

type OriginXML struct {
	ID                    string                 `xml:"Id"`
	DomainName            string                 `xml:"DomainName"`
	OriginPath            string                 `xml:"OriginPath,omitempty"`
	S3OriginConfig        *S3OriginConfigXML     `xml:"S3OriginConfig,omitempty"`
	CustomOriginConfig    *CustomOriginConfigXML `xml:"CustomOriginConfig,omitempty"`
	ConnectionAttempts    int                    `xml:"ConnectionAttempts,omitempty"`
	ConnectionTimeout     int                    `xml:"ConnectionTimeout,omitempty"`
	OriginAccessControlID string                 `xml:"OriginAccessControlId,omitempty"`
}

OriginXML represents an origin in XML format.

type Origins

type Origins struct {
	Quantity int
	Items    []Origin
}

Origins represents the origins for a distribution.

type OriginsXML

type OriginsXML struct {
	Quantity int         `xml:"Quantity"`
	Items    *OriginList `xml:"Items,omitempty"`
}

OriginsXML represents origins in XML format.

type Paths

type Paths struct {
	Quantity int
	Items    []string
}

Paths represents paths to invalidate.

type PathsXML

type PathsXML struct {
	Quantity int      `xml:"Quantity"`
	Items    []string `xml:"Items>Path,omitempty"`
}

PathsXML represents paths in XML format.

type PublicKey added in v0.22.0

type PublicKey struct {
	ID              string
	CreatedTime     time.Time
	ETag            string
	PublicKeyConfig *PublicKeyConfig
}

PublicKey is a CloudFront-managed RSA public key. Used as a building block for signed URL / signed cookie verification: a KeyGroup references one or more PublicKeys, and a Distribution references KeyGroups via TrustedKeyGroups on a CacheBehavior.

type PublicKeyConfig added in v0.22.0

type PublicKeyConfig struct {
	CallerReference string
	Name            string
	EncodedKey      string // PEM-encoded RSA public key
	Comment         string
}

PublicKeyConfig is the user-supplied configuration of a PublicKey.

type PublicKeyConfigXML added in v0.22.0

type PublicKeyConfigXML struct {
	XMLName         xml.Name `xml:"PublicKeyConfig"`
	Xmlns           string   `xml:"xmlns,attr,omitempty"`
	CallerReference string   `xml:"CallerReference"`
	Name            string   `xml:"Name"`
	EncodedKey      string   `xml:"EncodedKey"`
	Comment         string   `xml:"Comment,omitempty"`
}

PublicKeyConfigXML is the XML view of PublicKeyConfig — also used as the request body for CreatePublicKey.

type PublicKeyListXML added in v0.22.0

type PublicKeyListXML struct {
	XMLName  xml.Name              `xml:"PublicKeyList"`
	Xmlns    string                `xml:"xmlns,attr"`
	MaxItems int                   `xml:"MaxItems"`
	Quantity int                   `xml:"Quantity"`
	Items    []PublicKeySummaryXML `xml:"Items>PublicKeySummary,omitempty"`
}

PublicKeyListXML is the body of ListPublicKeys.

type PublicKeyResultXML added in v0.22.0

type PublicKeyResultXML struct {
	XMLName         xml.Name            `xml:"PublicKey"`
	Xmlns           string              `xml:"xmlns,attr"`
	ID              string              `xml:"Id"`
	CreatedTime     string              `xml:"CreatedTime"`
	PublicKeyConfig *PublicKeyConfigXML `xml:"PublicKeyConfig"`
}

PublicKeyResultXML is the XML body of GetPublicKey / CreatePublicKey responses.

type PublicKeySummaryXML added in v0.22.0

type PublicKeySummaryXML struct {
	ID          string `xml:"Id"`
	Name        string `xml:"Name"`
	CreatedTime string `xml:"CreatedTime"`
	EncodedKey  string `xml:"EncodedKey"`
	Comment     string `xml:"Comment,omitempty"`
}

PublicKeySummaryXML is one item in PublicKeyList.

type QueryStringCacheKeys

type QueryStringCacheKeys struct {
	Quantity int
	Items    []string
}

QueryStringCacheKeys represents query string cache keys.

type RestrictionsXML

type RestrictionsXML struct {
	GeoRestriction *GeoRestrictionXML `xml:"GeoRestriction"`
}

RestrictionsXML represents restrictions in XML format.

type S3OriginConfig

type S3OriginConfig struct {
	OriginAccessIdentity string
}

S3OriginConfig represents S3 origin configuration.

type S3OriginConfigXML

type S3OriginConfigXML struct {
	OriginAccessIdentity string `xml:"OriginAccessIdentity"`
}

S3OriginConfigXML represents S3 origin config in XML format.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implements the CloudFront service.

func New

func New(storage Storage) *Service

New creates a new CloudFront service.

func (*Service) Close added in v0.6.0

func (s *Service) Close() error

Close saves the storage state if persistence is enabled.

func (*Service) CreateDistribution

func (s *Service) CreateDistribution(w http.ResponseWriter, r *http.Request)

CreateDistribution handles the CreateDistribution operation.

func (*Service) CreateInvalidation

func (s *Service) CreateInvalidation(w http.ResponseWriter, r *http.Request)

CreateInvalidation handles the CreateInvalidation operation.

func (*Service) CreateKeyGroup added in v0.22.0

func (s *Service) CreateKeyGroup(w http.ResponseWriter, r *http.Request)

CreateKeyGroup handles POST /2020-05-31/key-group.

func (*Service) CreatePublicKey added in v0.22.0

func (s *Service) CreatePublicKey(w http.ResponseWriter, r *http.Request)

CreatePublicKey handles POST /2020-05-31/public-key.

func (*Service) DeleteDistribution

func (s *Service) DeleteDistribution(w http.ResponseWriter, r *http.Request)

DeleteDistribution handles the DeleteDistribution operation.

func (*Service) DeleteKeyGroup added in v0.22.0

func (s *Service) DeleteKeyGroup(w http.ResponseWriter, r *http.Request)

DeleteKeyGroup handles DELETE /2020-05-31/key-group/{id}.

func (*Service) DeletePublicKey added in v0.22.0

func (s *Service) DeletePublicKey(w http.ResponseWriter, r *http.Request)

DeletePublicKey handles DELETE /2020-05-31/public-key/{id}.

func (*Service) Edge added in v0.21.0

func (s *Service) Edge(w http.ResponseWriter, r *http.Request)

Edge handles requests routed through `/kumo/cdn/{distId}/{path...}`. It implements the CloudFront edge caching contract:

  1. Resolve the distribution + chosen origin.
  2. For non-safe methods (PUT / POST / DELETE / PATCH), pass through to the origin without consulting or storing the cache.
  3. For safe methods (GET / HEAD), look up the cache.
  4. If fresh: - client conditional (If-None-Match / If-Modified-Since) satisfied by the cached entry → 304 Not Modified - Range request → 206 Partial Content from the cached body - otherwise → 200 with `X-Cache: Hit from kumo` and `Age`
  5. If stale or MustRevalidate: revalidate with the origin using conditional headers built from the cached validators. 304 from origin extends the entry's freshness; 200 replaces it.
  6. On a true miss: fetch, evaluate cacheability + TTL via `cache/`, store when allowed, and serve with `X-Cache: Miss from kumo`.

func (*Service) GetDistribution

func (s *Service) GetDistribution(w http.ResponseWriter, r *http.Request)

GetDistribution handles the GetDistribution operation.

func (*Service) GetDistributionConfig

func (s *Service) GetDistributionConfig(w http.ResponseWriter, r *http.Request)

GetDistributionConfig handles the GetDistributionConfig operation.

func (*Service) GetInvalidation

func (s *Service) GetInvalidation(w http.ResponseWriter, r *http.Request)

GetInvalidation handles the GetInvalidation operation.

func (*Service) GetKeyGroup added in v0.22.0

func (s *Service) GetKeyGroup(w http.ResponseWriter, r *http.Request)

GetKeyGroup handles GET /2020-05-31/key-group/{id}.

func (*Service) GetPublicKey added in v0.22.0

func (s *Service) GetPublicKey(w http.ResponseWriter, r *http.Request)

GetPublicKey handles GET /2020-05-31/public-key/{id}.

func (*Service) ListDistributions

func (s *Service) ListDistributions(w http.ResponseWriter, r *http.Request)

ListDistributions handles the ListDistributions operation.

func (*Service) ListKeyGroups added in v0.22.0

func (s *Service) ListKeyGroups(w http.ResponseWriter, r *http.Request)

ListKeyGroups handles GET /2020-05-31/key-group.

func (*Service) ListPublicKeys added in v0.22.0

func (s *Service) ListPublicKeys(w http.ResponseWriter, r *http.Request)

ListPublicKeys handles GET /2020-05-31/public-key.

func (*Service) Name

func (s *Service) Name() string

Name returns the service name.

func (*Service) RegisterRoutes

func (s *Service) RegisterRoutes(r service.Router)

RegisterRoutes registers the CloudFront routes.

func (*Service) UpdateDistribution

func (s *Service) UpdateDistribution(w http.ResponseWriter, r *http.Request)

UpdateDistribution handles the UpdateDistribution operation.

type Storage

type Storage interface {
	CreateDistribution(ctx context.Context, config *CreateDistributionRequest) (*Distribution, error)
	GetDistribution(ctx context.Context, id string) (*Distribution, error)
	ListDistributions(ctx context.Context, marker string, maxItems int) ([]*Distribution, string, error)
	UpdateDistribution(ctx context.Context, id string, config *CreateDistributionRequest, etag string) (*Distribution, error)
	DeleteDistribution(ctx context.Context, id string, etag string) error
	CreateInvalidation(ctx context.Context, distributionID string, batch *CreateInvalidationRequest) (*Invalidation, error)
	GetInvalidation(ctx context.Context, distributionID, invalidationID string) (*Invalidation, error)
	ListInvalidations(ctx context.Context, distributionID, marker string, maxItems int) ([]*Invalidation, string, error)

	// Signed URL building blocks.
	CreatePublicKey(ctx context.Context, cfg *PublicKeyConfig) (*PublicKey, error)
	GetPublicKey(ctx context.Context, id string) (*PublicKey, error)
	ListPublicKeys(ctx context.Context) []*PublicKey
	DeletePublicKey(ctx context.Context, id string) error

	CreateKeyGroup(ctx context.Context, cfg *KeyGroupConfig) (*KeyGroup, error)
	GetKeyGroup(ctx context.Context, id string) (*KeyGroup, error)
	ListKeyGroups(ctx context.Context) []*KeyGroup
	DeleteKeyGroup(ctx context.Context, id string) error
}

Storage defines the CloudFront storage interface.

type TrustedKeyGroups

type TrustedKeyGroups struct {
	Enabled  bool
	Quantity int
	Items    []string
}

TrustedKeyGroups represents trusted key groups.

type TrustedKeyGroupsXML

type TrustedKeyGroupsXML struct {
	Enabled  bool     `xml:"Enabled"`
	Quantity int      `xml:"Quantity"`
	Items    []string `xml:"Items>KeyGroup,omitempty"`
}

TrustedKeyGroupsXML represents trusted key groups in XML format.

type TrustedSigners

type TrustedSigners struct {
	Enabled  bool
	Quantity int
	Items    []string
}

TrustedSigners represents trusted signers.

type TrustedSignersXML

type TrustedSignersXML struct {
	Enabled  bool     `xml:"Enabled"`
	Quantity int      `xml:"Quantity"`
	Items    []string `xml:"Items>AwsAccountNumber,omitempty"`
}

TrustedSignersXML represents trusted signers in XML format.

type ViewerCertificate

type ViewerCertificate struct {
	CloudFrontDefaultCertificate bool
	IAMCertificateID             string
	ACMCertificateArn            string
	SSLSupportMethod             string
	MinimumProtocolVersion       string
	Certificate                  string
	CertificateSource            string
}

ViewerCertificate represents viewer certificate configuration.

type ViewerCertificateXML

type ViewerCertificateXML struct {
	CloudFrontDefaultCertificate bool   `xml:"CloudFrontDefaultCertificate,omitempty"`
	IAMCertificateID             string `xml:"IAMCertificateId,omitempty"`
	ACMCertificateArn            string `xml:"ACMCertificateArn,omitempty"`
	MinimumProtocolVersion       string `xml:"MinimumProtocolVersion,omitempty"`
	SSLSupportMethod             string `xml:"SSLSupportMethod,omitempty"`
}

ViewerCertificateXML represents viewer certificate in XML format.

Directories

Path Synopsis
Package cache implements the cache rule evaluation CloudFront performs at the edge, per RFC 7234 + the CloudFront-specific extensions documented at:
Package cache implements the cache rule evaluation CloudFront performs at the edge, per RFC 7234 + the CloudFront-specific extensions documented at:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL