Help us shape the future of Go! Take the 2026 Go Developer Survey

cloudfront

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package cloudfront emulates Amazon CloudFront (REST-XML, global): distributions with their invalidations, tags and monitoring subscriptions; cache, origin request and response headers policies (the managed ones built in); origin access controls and identities; key groups and public keys; and CloudFront Functions. Distributions serve traffic on <id>.cloudfront.localhost (edge.go).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Distribution

type Distribution struct {
	Id            string          `json:"id"`
	ARN           string          `json:"arn"`
	Account       string          `json:"account"`
	ETag          string          `json:"etag"`
	Config        string          `json:"config"` // inner XML of DistributionConfig
	Modified      time.Time       `json:"modified"`
	Monitoring    string          `json:"monitoring,omitempty"` // inner XML of MonitoringSubscription
	Invalidations []*Invalidation `json:"invalidations,omitempty"`
}

Distribution keeps its DistributionConfig as sent: Terraform compares it field by field, so it round-trips untouched.

type Function

type Function struct {
	Name    string    `json:"name"`
	ARN     string    `json:"arn"`
	Account string    `json:"account"`
	Created time.Time `json:"created"`
	Dev     *Stage    `json:"dev"`
	Live    *Stage    `json:"live,omitempty"`
}

Function is a CloudFront Function: DEVELOPMENT and, once published, LIVE.

type Invalidation

type Invalidation struct {
	Id        string    `json:"id"`
	Created   time.Time `json:"created"`
	CallerRef string    `json:"callerRef"`
	Batch     string    `json:"batch"` // inner XML of InvalidationBatch
}

Invalidation purges cached paths when it is created; it reads back as Completed.

type Item

type Item struct {
	Id       string    `json:"id"`
	Kind     string    `json:"kind"`    // kind.Elem
	Account  string    `json:"account"` // "" for managed policies
	ETag     string    `json:"etag"`
	Config   string    `json:"config"` // inner XML of <Kind>Config
	Modified time.Time `json:"modified"`
	Extra    string    `json:"extra,omitempty"` // S3CanonicalUserId of an origin access identity
}

Item is a resource defined by one config document: a cache, origin request or response headers policy, an origin access control or identity, a key group or a public key.

type Service

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

Service is the CloudFront emulator.

func New

func New(hub *core.Hub) *Service

New creates the CloudFront service.

func (*Service) Info

func (s *Service) Info() core.Info

func (*Service) Inspect

func (s *Service) Inspect(table, id string) any

Inspect returns a distribution, function or policy as stored.

func (*Service) Load

func (s *Service) Load(b []byte) error

func (*Service) Reset

func (s *Service) Reset()

func (*Service) Resources

func (s *Service) Resources() []core.Table

Resources lists distributions, functions and the config-document resources.

func (*Service) Save

func (s *Service) Save() ([]byte, error)

func (*Service) ServeHTTP

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

type Stage

type Stage struct {
	Config    string    `json:"config"` // inner XML of FunctionConfig
	Code      []byte    `json:"code"`
	ETag      string    `json:"etag"`
	Modified  time.Time `json:"modified"`
	Published bool      `json:"published,omitempty"` // DEVELOPMENT is what LIVE runs
}

Stage is one stage of a function.

Jump to

Keyboard shortcuts

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