cloudfront

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleRESTRequest

func HandleRESTRequest(ctx *service.RequestContext, store *Store, locator ServiceLocator) (*service.Response, error)

HandleRESTRequest routes CloudFront REST-XML requests based on path and method.

Types

type CacheBehavior

type CacheBehavior struct {
	PathPattern          string
	TargetOriginID       string
	ViewerProtocolPolicy string
	AllowedMethods       []string
	CachedMethods        []string
	ForwardedValues      *ForwardedValues
	MinTTL               int64
	MaxTTL               int64
	DefaultTTL           int64
	Compress             bool
}

CacheBehavior represents a cache behavior.

type CachePolicy

type CachePolicy struct {
	ID                                       string
	Name                                     string
	Comment                                  string
	DefaultTTL                               int64
	MaxTTL                                   int64
	MinTTL                                   int64
	ParametersInCacheKeyAndForwardedToOrigin map[string]any
	ETag                                     string
	LastModified                             time.Time
}

CachePolicy represents a CloudFront cache policy.

type CloudFrontService

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

CloudFrontService is the cloudmock implementation of the AWS CloudFront API.

func New

func New(accountID, region string) *CloudFrontService

New returns a new CloudFrontService for the given AWS account ID and region.

func NewWithLocator

func NewWithLocator(accountID, region string, locator ServiceLocator) *CloudFrontService

NewWithLocator returns a new CloudFrontService with a service locator for cross-service communication.

func (*CloudFrontService) Actions

func (s *CloudFrontService) Actions() []service.Action

Actions returns the list of CloudFront API actions supported by this service. CloudFront uses REST-XML path-based routing, so these are descriptive only.

func (*CloudFrontService) HandleRequest

func (s *CloudFrontService) HandleRequest(ctx *service.RequestContext) (*service.Response, error)

HandleRequest routes an incoming CloudFront request to the appropriate handler. CloudFront uses REST-XML path-based routing.

func (*CloudFrontService) HealthCheck

func (s *CloudFrontService) HealthCheck() error

HealthCheck always returns nil (no external dependencies).

func (*CloudFrontService) Name

func (s *CloudFrontService) Name() string

Name returns the AWS service name used for routing.

func (*CloudFrontService) ResourceSchemas

func (s *CloudFrontService) ResourceSchemas() []schema.ResourceSchema

ResourceSchemas returns the schema for CloudFront resource types.

func (*CloudFrontService) SetLocator

func (s *CloudFrontService) SetLocator(locator ServiceLocator)

SetLocator sets the service locator for cross-service communication (S3/ELB origin validation).

type CustomOriginConfig

type CustomOriginConfig struct {
	HTTPPort             int
	HTTPSPort            int
	OriginProtocolPolicy string
}

CustomOriginConfig holds custom origin settings.

type Distribution

type Distribution struct {
	ID                   string
	ARN                  string
	DomainName           string
	Status               string // Deployed, InProgress
	Enabled              bool
	Comment              string
	DefaultRootObject    string
	PriceClass           string
	Origins              []Origin
	DefaultCacheBehavior *CacheBehavior
	CacheBehaviors       []CacheBehavior
	CallerReference      string
	ETag                 string
	LastModified         time.Time
	Tags                 map[string]string
	Lifecycle            *lifecycle.Machine
}

Distribution represents a CloudFront distribution.

type ForwardedValues

type ForwardedValues struct {
	QueryString bool
	Cookies     string // none, whitelist, all
	Headers     []string
}

ForwardedValues controls what is forwarded to the origin.

type Function

type Function struct {
	Name           string
	Comment        string
	Runtime        string // cloudfront-js-1.0, cloudfront-js-2.0
	Stage          string // DEVELOPMENT, LIVE
	Status         string // UNPUBLISHED, DEPLOYED
	ARN            string
	FunctionCode   []byte
	CreatedAt      time.Time
	LastModifiedAt time.Time
	ETag           string
}

Function represents a CloudFront Function.

type Invalidation

type Invalidation struct {
	ID              string
	DistributionID  string
	Status          string // InProgress, Completed
	CallerReference string
	Paths           []string
	CreateTime      time.Time
	Lifecycle       *lifecycle.Machine
}

Invalidation represents a CloudFront invalidation.

type Origin

type Origin struct {
	ID           string
	DomainName   string
	OriginPath   string
	S3Config     *S3OriginConfig
	CustomConfig *CustomOriginConfig
}

Origin represents a CloudFront origin.

type OriginRequestPolicy

type OriginRequestPolicy struct {
	ID                 string
	Name               string
	Comment            string
	HeadersConfig      map[string]any
	CookiesConfig      map[string]any
	QueryStringsConfig map[string]any
	ETag               string
	LastModified       time.Time
}

OriginRequestPolicy represents a CloudFront origin request policy.

type S3OriginConfig

type S3OriginConfig struct {
	OriginAccessIdentity string
}

S3OriginConfig holds S3-specific origin settings.

type ServiceLocator

type ServiceLocator interface {
	Lookup(name string) (service.Service, error)
}

ServiceLocator provides access to other services for cross-service communication.

type Store

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

Store manages all CloudFront resources.

func NewStore

func NewStore(accountID, region string) *Store

NewStore returns a new Store for the given account and region.

func (*Store) CreateCachePolicy

func (s *Store) CreateCachePolicy(name, comment string, defaultTTL, maxTTL, minTTL int64, params map[string]any) (*CachePolicy, bool)

func (*Store) CreateDistribution

func (s *Store) CreateDistribution(callerRef, comment, defaultRootObject, priceClass string, enabled bool, origins []Origin, defaultBehavior *CacheBehavior, behaviors []CacheBehavior) *Distribution

func (*Store) CreateFunction

func (s *Store) CreateFunction(name, comment, runtime string, code []byte) (*Function, bool)

func (*Store) CreateInvalidation

func (s *Store) CreateInvalidation(distID, callerRef string, paths []string) (*Invalidation, bool)

func (*Store) CreateOriginRequestPolicy

func (s *Store) CreateOriginRequestPolicy(name, comment string, headersConfig, cookiesConfig, queryStringsConfig map[string]any) (*OriginRequestPolicy, bool)

func (*Store) DeleteCachePolicy

func (s *Store) DeleteCachePolicy(id, ifMatch string) (bool, error)

func (*Store) DeleteDistribution

func (s *Store) DeleteDistribution(id, ifMatch string) (bool, error)

DeleteDistribution removes a distribution. Returns specific error strings for not-found or not-disabled cases.

func (*Store) DeleteFunction

func (s *Store) DeleteFunction(name, ifMatch string) (bool, error)

func (*Store) DeleteOriginRequestPolicy

func (s *Store) DeleteOriginRequestPolicy(id, ifMatch string) (bool, error)

func (*Store) FindByCallerReference

func (s *Store) FindByCallerReference(callerRef string) (*Distribution, bool)

FindByCallerReference returns an existing distribution with the same CallerReference, if any.

func (*Store) GetCachePolicy

func (s *Store) GetCachePolicy(id string) (*CachePolicy, bool)

func (*Store) GetDistribution

func (s *Store) GetDistribution(id string) (*Distribution, bool)

func (*Store) GetFunction

func (s *Store) GetFunction(name, stage string) (*Function, bool)

func (*Store) GetInvalidation

func (s *Store) GetInvalidation(distID, invID string) (*Invalidation, bool)

func (*Store) GetOriginRequestPolicy

func (s *Store) GetOriginRequestPolicy(id string) (*OriginRequestPolicy, bool)

func (*Store) ListCachePolicies

func (s *Store) ListCachePolicies() []*CachePolicy

func (*Store) ListDistributions

func (s *Store) ListDistributions() []*Distribution

func (*Store) ListFunctions

func (s *Store) ListFunctions(stage string) []*Function

func (*Store) ListInvalidations

func (s *Store) ListInvalidations(distID string) ([]*Invalidation, bool)

func (*Store) ListOriginRequestPolicies

func (s *Store) ListOriginRequestPolicies() []*OriginRequestPolicy

func (*Store) ListTagsForResource

func (s *Store) ListTagsForResource(arn string) (map[string]string, bool)

func (*Store) PublishFunction

func (s *Store) PublishFunction(name, ifMatch string) (*Function, bool, error)

func (*Store) TagResource

func (s *Store) TagResource(arn string, tags map[string]string) bool

func (*Store) TestFunction

func (s *Store) TestFunction(name, stage string, eventObject []byte) (map[string]any, bool)

TestFunction simulates running a CloudFront function against test event data. Returns computed result (event echo) or error.

func (*Store) UntagResource

func (s *Store) UntagResource(arn string, keys []string) bool

func (*Store) UpdateCachePolicy

func (s *Store) UpdateCachePolicy(id, ifMatch, name, comment string, defaultTTL, maxTTL, minTTL int64, params map[string]any) (*CachePolicy, bool, error)

func (*Store) UpdateDistribution

func (s *Store) UpdateDistribution(id, ifMatch, comment, defaultRootObject, priceClass string, enabled *bool, origins []Origin, defaultBehavior *CacheBehavior, behaviors []CacheBehavior) (*Distribution, bool, error)

UpdateDistribution updates a distribution. Returns (dist, true) on success, (nil, false) if not found, and specific errors for ETag/enabled state issues.

func (*Store) UpdateFunction

func (s *Store) UpdateFunction(name, ifMatch, comment, runtime string, code []byte) (*Function, bool, error)

Jump to

Keyboard shortcuts

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