Documentation
¶
Overview ¶
Package localcloudfront derives a local delivery gateway from the AWS::CloudFront::Distribution resources in a synthesized cloud assembly.
The distribution, its cache behaviors, origins and the AWS::CloudFront::* resources it references are the only routing definition. The package runs the exact CloudFront Function code the template declares, applies the origin request and response headers policies, and hands origin requests to an Origin implementation. It is not a CloudFront emulator: the cache is a single in-memory store, there is no edge network and no TLS.
Index ¶
- Constants
- Variables
- func CacheKey(host, method, path, rawQuery string, header http.Header, policy *CachePolicy) string
- func CacheKeyQuery(rawQuery string, policy *CachePolicy) string
- func DistributionID(logicalID string) string
- func FilterS3ResponseOverrides(raw string) string
- func ManagedPolicyIDs(kind PolicyKind) []string
- func MatchPathPattern(pattern, requestPath string) bool
- func PropertyInventory() map[string]map[string]Disposition
- func ReportViewerCountry(distributions []*Distribution, hasCountry bool)
- func ValidateInvalidationPaths(paths []string) error
- type Behavior
- type BehaviorStats
- type CORSConfig
- type Cache
- type CacheControl
- type CacheEntry
- func (e CacheEntry) Fresh(now time.Time) bool
- func (e CacheEntry) ServeStaleForErrorResponse(now time.Time, errorWindow, maxTTL time.Duration) bool
- func (e CacheEntry) ServeStaleIfError(now time.Time, maxTTL time.Duration) bool
- func (e CacheEntry) ServeStaleWhileRevalidate(now time.Time, maxTTL time.Duration) bool
- func (e CacheEntry) ViewerPath() string
- type CachePolicy
- type ContentSecurityPolicy
- type ContentTypeOptions
- type ContentTypeProfile
- type ContentTypeProfileConfig
- type CookieForwarding
- type CookieValue
- type CustomErrorResponse
- type CustomHeader
- type CustomOrigin
- type Disposition
- type Distribution
- func (d *Distribution) BehaviorForURI(uri string) *Behavior
- func (d *Distribution) CustomErrorResponseFor(status int) (CustomErrorResponse, bool)
- func (d *Distribution) ExplicitBehaviorForURI(uri string) (*Behavior, bool)
- func (d *Distribution) Origin(id string) (*DistributionOrigin, bool)
- func (d *Distribution) OriginGroup(id string) (*OriginGroup, bool)
- func (d *Distribution) Servable() bool
- type DistributionOrigin
- type EdgeBody
- type EdgeCF
- type EdgeConfig
- type EdgeCustomOrigin
- type EdgeEvent
- type EdgeExecutionError
- type EdgeFunction
- type EdgeHeader
- type EdgeInvoker
- type EdgeOrigin
- type EdgeOutcome
- type EdgeRecord
- type EdgeRequest
- type EdgeResponse
- type EdgeS3Origin
- type EdgeStatus
- type EdgeValidationError
- type EncryptionEntity
- type Event
- type EventContext
- type EventRequest
- type EventResponse
- type Executor
- type FieldLevelEncryptionConfig
- type FieldLevelEncryptionOutcome
- type FieldLevelEncryptionProfile
- type ForwardingMode
- type FrameOptions
- type Function
- type FunctionError
- type FunctionResult
- type Gateway
- type GeoRestriction
- type HeaderForwarding
- type HeaderValue
- type Invalidation
- type InvalidationAPI
- type InvalidationPathError
- type KeyGroup
- type KeyValueStore
- type Origin
- type OriginAccessControl
- type OriginFunc
- type OriginGroup
- type OriginGroupMember
- type OriginGroupOrigin
- type OriginKind
- type OriginRequest
- type OriginRequestPolicy
- type OriginResponse
- type OriginUnavailableError
- type Policy
- type PolicyKind
- type PublicKey
- type QueryArgProfile
- type QueryArgProfileConfig
- type QueryForwarding
- type QueryString
- type ReferrerPolicy
- type Resource
- type ResponseBody
- type ResponseHeadersPolicy
- type ResultKind
- type S3Origin
- type SecurityHeaders
- type StreamOrigin
- type StreamResponse
- type StrictTransportSecurity
- type Template
- type Topology
- func (t *Topology) Distribution(logicalID string) (*Distribution, bool)
- func (t *Topology) FieldLevelEncryptionConfig(logicalID string) (*FieldLevelEncryptionConfig, bool)
- func (t *Topology) FieldLevelEncryptionProfile(logicalID string) (*FieldLevelEncryptionProfile, bool)
- func (t *Topology) Function(logicalID string) (*Function, bool)
- func (t *Topology) KeyGroup(logicalID string) (*KeyGroup, bool)
- func (t *Topology) KeyValueStore(logicalID string) (*KeyValueStore, bool)
- func (t *Topology) PublicKey(logicalID string) (*PublicKey, bool)
- type TrustedKeyGroups
- type Viewer
- type XSSProtection
Constants ¶
const DefaultOriginResponseTimeout = 30 * time.Second
DefaultOriginResponseTimeout is the default CloudFront origin response timeout. It applies "after receiving a packet of a response from the origin and before receiving the next packet". https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html
Variables ¶
ErrOriginUnavailable is the sentinel for an origin the local gateway cannot serve.
ErrStreamUnavailable marks an origin that cannot stream a response.
Functions ¶
func CacheKey ¶
func CacheKey(host, method, path, rawQuery string, header http.Header, policy *CachePolicy) string
CacheKey builds the cache key for one request. The distribution domain and the URL path are always part of it; the cache policy adds the query strings, headers and cookies it names. "The OPTIONS method is included in the cache key for OPTIONS requests. This means that responses to OPTIONS requests are cached separately from responses to GET and HEAD requests." GET and HEAD therefore share one key; every other method, which CloudFront does not cache, keeps its own. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/understanding-the-cache-key.html
func CacheKeyQuery ¶
func CacheKeyQuery(rawQuery string, policy *CachePolicy) string
CacheKeyQuery returns the query-string part of the cache key for a viewer request. It is stored on the entry so an invalidation path can be matched against the path plus the query string the policy forwarded.
func DistributionID ¶
DistributionID derives the local physical id for a distribution logical id. It has the CloudFront id shape (an E followed by upper-case hex).
func FilterS3ResponseOverrides ¶
FilterS3ResponseOverrides removes the three response-content-* parameters from a raw query string. Every other parameter is kept in order.
func ManagedPolicyIDs ¶
func ManagedPolicyIDs(kind PolicyKind) []string
ManagedPolicyIDs returns the ids in the pinned table for one kind. Tests use it to prove the table covers every id a shipped construct references.
func MatchPathPattern ¶
MatchPathPattern applies CloudFront's path-pattern rules: a pattern may optionally begin with a slash, matching is case-sensitive, `*` matches zero or more characters and `?` matches exactly one character. The request path always begins with a slash; the default pattern `*` matches every path.
func PropertyInventory ¶
func PropertyInventory() map[string]map[string]Disposition
PropertyInventory returns the classification table for the properties the reader understands. Tests use it to prove that every property in a shipped template is classified.
func ReportViewerCountry ¶
func ReportViewerCountry(distributions []*Distribution, hasCountry bool)
ReportViewerCountry records what the run's --viewer-country can and cannot produce for CloudFront-Viewer-Country. The header is derivable when the run sets a country; otherwise the viewer's location is undetermined and the header is empty, and the report names the flag that would supply it.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/adding-cloudfront-headers.html
func ValidateInvalidationPaths ¶
ValidateInvalidationPaths applies the documented invalidation request rules: at least one path, no more than 3000 paths, every path starts with a slash, a path is at most 4000 characters, and "Don't use the ~ character in your path. CloudFront doesn't support this character for invalidations, whether it's URL-encoded or not." A trailing * is the wildcard; an asterisk anywhere else is a literal character, so it is not refused.
Types ¶
type Behavior ¶
type Behavior struct {
PathPattern string `json:"pathPattern"`
TargetOriginID string `json:"targetOriginId"`
AllowedMethods []string `json:"allowedMethods"`
CachedMethods []string `json:"cachedMethods,omitempty"`
ViewerProtocolPolicy string `json:"viewerProtocolPolicy,omitempty"`
CachePolicy *Policy `json:"cachePolicy,omitempty"`
OriginRequestPolicy *Policy `json:"originRequestPolicy,omitempty"`
ResponseHeadersPolicy *Policy `json:"responseHeadersPolicy,omitempty"`
ViewerRequestFunction string `json:"viewerRequestFunction,omitempty"`
ViewerResponseFunction string `json:"viewerResponseFunction,omitempty"`
// EdgeLambdas are the behavior's LambdaFunctionAssociations, keyed by event
// type.
EdgeLambdas map[string]*EdgeFunction `json:"edgeLambdas,omitempty"`
// TrustedKeyGroups requires a signed URL or signed cookie for every request
// except OPTIONS.
TrustedKeyGroups *TrustedKeyGroups `json:"trustedKeyGroups,omitempty"`
// FieldLevelEncryptionID names the AWS::CloudFront::FieldLevelEncryptionConfig
// the behavior applies.
FieldLevelEncryptionID string `json:"fieldLevelEncryptionId,omitempty"`
Compress bool `json:"compress,omitempty"`
// OriginResponseTimeout bounds the wait between packets of a streamed
// origin response. Zero uses DefaultOriginResponseTimeout.
OriginResponseTimeout time.Duration `json:"originResponseTimeout,omitempty"`
Reported []string `json:"reported,omitempty"`
Refusals []string `json:"refusals,omitempty"`
}
Behavior is one cache behavior.
type BehaviorStats ¶
BehaviorStats is one behavior's cache hit and miss counts.
type CORSConfig ¶
type CORSConfig struct {
AllowCredentials bool `json:"allowCredentials,omitempty"`
AllowHeaders []string `json:"allowHeaders,omitempty"`
AllowMethods []string `json:"allowMethods,omitempty"`
AllowOrigins []string `json:"allowOrigins,omitempty"`
ExposeHeaders []string `json:"exposeHeaders,omitempty"`
MaxAgeSeconds *int `json:"maxAgeSeconds,omitempty"`
OriginOverride bool `json:"originOverride,omitempty"`
}
CORSConfig is a response headers policy CORS section.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache stores origin responses for one distribution.
func (*Cache) Get ¶
func (c *Cache) Get(key string) (CacheEntry, bool)
Get returns the entry stored under key.
func (*Cache) Invalidate ¶
Invalidate removes every entry whose path matches one of the invalidation paths. A path must start with a slash and may contain the * wildcard. The return value is the number of entries removed.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html
type CacheControl ¶
type CacheControl struct {
NoCache bool
NoStore bool
Private bool
MaxAge *time.Duration
SMaxAge *time.Duration
StaleWhileRevalidate time.Duration
StaleIfError time.Duration
}
CacheControl is the origin Cache-Control subset CloudFront honors.
func ParseCacheControl ¶
func ParseCacheControl(values []string) CacheControl
ParseCacheControl reads the directives CloudFront uses. A malformed directive is ignored, as CloudFront ignores a header it cannot parse.
type CacheEntry ¶
type CacheEntry struct {
Response OriginResponse
// Path is the viewer path the entry was stored under, used by invalidations.
Path string
// Query is the query-string part of the cache key (the strings the cache
// policy selected from the viewer request). An invalidation path is matched
// against Path plus Query: "If you configured CloudFront to forward query
// strings to your origin, you must include the query strings when
// invalidating files."
// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/invalidation-specifying-objects.html
Query string
// StoredAt and ExpiresAt are on the gateway's clock.
StoredAt time.Time
ExpiresAt time.Time
// StaleWhileRevalidate and StaleIfError are the origin's Cache-Control
// extensions.
StaleWhileRevalidate time.Duration
StaleIfError time.Duration
}
CacheEntry is one cached origin response and its expiry.
func (CacheEntry) Fresh ¶
func (e CacheEntry) Fresh(now time.Time) bool
Fresh reports whether the entry is inside its TTL.
func (CacheEntry) ServeStaleForErrorResponse ¶
func (e CacheEntry) ServeStaleForErrorResponse(now time.Time, errorWindow, maxTTL time.Duration) bool
ServeStaleForErrorResponse reports whether an expired entry may be served because the origin answered with a 5xx status. The page: "If your origin returns a 5xx status code, CloudFront serves the object even though it has expired. For the duration of the error caching minimum TTL, CloudFront continues to respond to viewer requests by serving the object from the edge cache." A stale-if-error directive extends that window, and "CloudFront will only serve an object that is stale up to the specified maximum TTL value."
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/HTTPStatusCodes.html https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html
func (CacheEntry) ServeStaleIfError ¶
ServeStaleIfError reports whether a stale entry may be served because the origin failed. The Stale-If-Error section carries the same Maximum TTL note as stale-while-revalidate.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html
func (CacheEntry) ServeStaleWhileRevalidate ¶
ServeStaleWhileRevalidate reports whether a stale entry may be served while the gateway refreshes it. The page: "CloudFront will serve the stale content up to the value of the stale-while-revalidate directive or the value of the CloudFront maximum TTL, whichever is less. After the maximum TTL duration, the stale object won't be available from the edge cache, regardless of the stale-while-revalidate value."
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html
func (CacheEntry) ViewerPath ¶
func (e CacheEntry) ViewerPath() string
ViewerPath returns the invalidatable path: the stored path plus the selected query string, when the cache policy forwarded one.
type CachePolicy ¶
type CachePolicy struct {
Headers HeaderForwarding `json:"headers"`
Cookies CookieForwarding `json:"cookies"`
QueryStrings QueryForwarding `json:"queryStrings"`
// MinTTL, DefaultTTL and MaxTTL are the cache policy's TTL bounds in
// seconds. They apply as the Expiration page's table states.
MinTTL int `json:"minTtl"`
DefaultTTL int `json:"defaultTtl"`
MaxTTL int `json:"maxTtl"`
// CachingDisabled is the managed CachingDisabled policy: every request goes
// to the origin.
CachingDisabled bool `json:"cachingDisabled,omitempty"`
}
CachePolicy is a cache policy: what reaches the origin and how long the gateway may cache the origin response.
func (CachePolicy) OriginTTL ¶
func (c CachePolicy) OriginTTL(response OriginResponse, now time.Time) (time.Duration, CacheControl)
OriginTTL returns the cache duration for an origin response and the parsed Cache-Control directives.
type ContentSecurityPolicy ¶
ContentSecurityPolicy is a CSP header setting.
type ContentTypeOptions ¶
type ContentTypeOptions struct {
Override bool `json:"override"`
}
ContentTypeOptions is a X-Content-Type-Options setting.
type ContentTypeProfile ¶
type ContentTypeProfile struct {
ContentType string `json:"contentType"`
Format string `json:"format"`
ProfileID string `json:"profileId"`
}
ContentTypeProfile is one ContentTypeProfiles entry.
type ContentTypeProfileConfig ¶
type ContentTypeProfileConfig struct {
ForwardWhenContentTypeIsUnknown bool `json:"forwardWhenContentTypeIsUnknown"`
Profiles []ContentTypeProfile `json:"profiles,omitempty"`
}
ContentTypeProfileConfig maps the form content type to a profile.
type CookieForwarding ¶
type CookieForwarding struct {
Mode ForwardingMode `json:"mode"`
Names []string `json:"names,omitempty"`
}
CookieForwarding is a cookies config.
type CookieValue ¶
type CookieValue struct {
Value string `json:"value"`
Attributes string `json:"attributes,omitempty"`
MultiValue []CookieValue `json:"multiValue,omitempty"`
}
CookieValue is one response cookie: its value and the Set-Cookie attributes. MultiValue is set when the response carried the cookie name more than once.
type CustomErrorResponse ¶
type CustomErrorResponse struct {
ErrorCode int `json:"errorCode"`
// ResponsePagePath is the path CloudFront fetches when the origin answers
// ErrorCode. It is resolved through the distribution's cache behaviors:
// "CloudFront finds the first cache behavior in your distribution that has
// a path pattern that matches the path of the custom error page" and "The
// CloudFront edge location sends a request for the custom error page to the
// origin that is specified in the cache behavior."
// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/HTTPStatusCodes.html
ResponsePagePath string `json:"responsePagePath,omitempty"`
// ResponseCode is the status served with the custom page; 0 keeps the
// origin's status when no page is served.
ResponseCode int `json:"responseCode,omitempty"`
// ErrorCachingMinTTL is how long the error response is cached. It is a
// pointer so an explicit 0 (which disables error caching for a custom
// origin, and means one second for an S3 origin) is distinguished from an
// omitted value (the 10 second default). The page: "If you have caching
// enabled for an S3 bucket origin, and you configure an error caching
// minimum TTL of 0 seconds ... you will still see an error caching minimum
// TTL of 1 second for S3 origin errors ... This doesn't apply to other types
// of origins."
// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages-expiration.html
ErrorCachingMinTTL *int `json:"errorCachingMinTtl,omitempty"`
}
CustomErrorResponse is one DistributionConfig CustomErrorResponses entry.
type CustomHeader ¶
type CustomHeader struct {
Name string `json:"name"`
Value string `json:"value"`
Override bool `json:"override"`
}
CustomHeader is a custom response header setting.
type CustomOrigin ¶
type CustomOrigin struct {
ProtocolPolicy string `json:"protocolPolicy,omitempty"`
SSLProtocols []string `json:"sslProtocols,omitempty"`
HTTPPort *int `json:"httpPort,omitempty"`
HTTPSPort *int `json:"httpsPort,omitempty"`
KeepaliveSeconds *int `json:"keepaliveSeconds,omitempty"`
ReadTimeout *int `json:"readTimeout,omitempty"`
}
CustomOrigin is a CustomOriginConfig the gateway reports.
type Disposition ¶
type Disposition string
Disposition says what the gateway does with a template property.
const ( // Implemented means the property changes local routing, forwarding or // response content and the gateway applies it. Implemented Disposition = "implemented" // Reported means the property is recorded in the distribution's report but // is not emulated locally. Reported Disposition = "reported" // Refused means a distribution that carries a non-empty value for the // property is not served. Refused Disposition = "refused" )
type Distribution ¶
type Distribution struct {
LogicalID string `json:"logicalId"`
Stack string `json:"stack"`
Comment string `json:"comment,omitempty"`
Enabled bool `json:"enabled"`
Aliases []string `json:"aliases,omitempty"`
DefaultRootObject string `json:"defaultRootObject,omitempty"`
DefaultBehavior *Behavior `json:"defaultBehavior"`
CacheBehaviors []*Behavior `json:"cacheBehaviors,omitempty"`
Origins []*DistributionOrigin `json:"origins"`
OriginGroups []*OriginGroup `json:"originGroups,omitempty"`
// CustomErrorResponses are the distribution's CustomErrorResponses, in the
// template's order.
CustomErrorResponses []CustomErrorResponse `json:"customErrorResponses,omitempty"`
// GeoRestriction is DistributionConfig Restrictions.GeoRestriction.
GeoRestriction *GeoRestriction `json:"geoRestriction,omitempty"`
Reported []string `json:"reported,omitempty"`
Refusals []string `json:"refusals,omitempty"`
}
Distribution is one AWS::CloudFront::Distribution the gateway can serve.
func (*Distribution) BehaviorForURI ¶
func (d *Distribution) BehaviorForURI(uri string) *Behavior
BehaviorForURI selects the cache behavior CloudFront would select for the original viewer URI: cache behaviors in listed order, then the default.
func (*Distribution) CustomErrorResponseFor ¶
func (d *Distribution) CustomErrorResponseFor(status int) (CustomErrorResponse, bool)
CustomErrorResponseFor returns the configured error response for a status.
func (*Distribution) ExplicitBehaviorForURI ¶
func (d *Distribution) ExplicitBehaviorForURI(uri string) (*Behavior, bool)
ExplicitBehaviorForURI reports the configured cache behavior (not the default behavior) whose path pattern matches uri. CloudFront's custom-error-page note distinguishes a cache behavior configured for the page path from the default behavior: "If you also configured a cache behavior for the same custom error page, CloudFront uses the cache behavior TTL instead."
func (*Distribution) Origin ¶
func (d *Distribution) Origin(id string) (*DistributionOrigin, bool)
Origin returns an origin by id.
func (*Distribution) OriginGroup ¶
func (d *Distribution) OriginGroup(id string) (*OriginGroup, bool)
OriginGroup returns an origin group by id.
func (*Distribution) Servable ¶
func (d *Distribution) Servable() bool
Servable reports whether every property the distribution uses is either implemented or reported without changing routing or response content.
type DistributionOrigin ¶
type DistributionOrigin struct {
ID string `json:"id"`
DomainName string `json:"domainName,omitempty"`
DomainExpression string `json:"domainExpression,omitempty"`
Kind OriginKind `json:"kind,omitempty"`
OriginPath string `json:"originPath,omitempty"`
Bucket string `json:"bucket,omitempty"`
FunctionURL string `json:"functionUrl,omitempty"`
// LocalURL is the loopback URL a run flag maps an external custom origin to.
LocalURL string `json:"localUrl,omitempty"`
OriginAccessControl string `json:"originAccessControl,omitempty"`
Custom *CustomOrigin `json:"customOrigin,omitempty"`
S3 *S3Origin `json:"s3Origin,omitempty"`
CustomHeaders map[string]string `json:"customHeaders,omitempty"`
Reported []string `json:"reported,omitempty"`
Refusals []string `json:"refusals,omitempty"`
}
DistributionOrigin is one distribution origin.
type EdgeBody ¶
type EdgeBody struct {
InputTruncated bool `json:"inputTruncated"`
Action string `json:"action,omitempty"`
Encoding string `json:"encoding,omitempty"`
Data string `json:"data,omitempty"`
// contains filtered or unexported fields
}
EdgeBody is the body object. A generated response may return the body as a plain JSON string instead of {encoding, data}; both forms are accepted.
func (*EdgeBody) UnmarshalJSON ¶
UnmarshalJSON accepts the object form and the plain-string body form.
type EdgeCF ¶
type EdgeCF struct {
Config EdgeConfig `json:"config"`
Request *EdgeRequest `json:"request,omitempty"`
Response *EdgeResponse `json:"response,omitempty"`
}
EdgeCF is the cf object. The origin object is part of the request object, not the cf object.
type EdgeConfig ¶
type EdgeConfig struct {
DistributionDomainName string `json:"distributionDomainName"`
DistributionID string `json:"distributionId"`
EventType string `json:"eventType"`
RequestID string `json:"requestId"`
}
EdgeConfig is the config object.
type EdgeCustomOrigin ¶
type EdgeCustomOrigin struct {
CustomHeaders map[string][]EdgeHeader `json:"customHeaders,omitempty"`
DomainName string `json:"domainName"`
Path string `json:"path"`
Port int `json:"port"`
Protocol string `json:"protocol"`
ReadTimeout int `json:"readTimeout,omitempty"`
KeepaliveTimeout int `json:"keepaliveTimeout,omitempty"`
ResponseCompletionTimeout int `json:"responseCompletionTimeout,omitempty"`
SSLProtocols []string `json:"sslProtocols,omitempty"`
}
EdgeCustomOrigin is a custom origin description.
type EdgeEvent ¶
type EdgeEvent struct {
Records []EdgeRecord `json:"Records"`
}
EdgeEvent is the Lambda@Edge event object.
type EdgeExecutionError ¶
EdgeExecutionError is a function that threw or did not finish. CloudFront answers 503 for unhandled exceptions in the function code.
func (*EdgeExecutionError) Error ¶
func (e *EdgeExecutionError) Error() string
type EdgeFunction ¶
type EdgeFunction struct {
EventType string `json:"eventType"`
Version string `json:"version"`
Function string `json:"function"`
IncludeBody bool `json:"includeBody,omitempty"`
Timeout time.Duration `json:"-"`
Refusals []string `json:"refusals,omitempty"`
}
EdgeFunction is one LambdaFunctionAssociations entry resolved to an AWS::Lambda::Version in the assembly.
func (*EdgeFunction) Servable ¶
func (e *EdgeFunction) Servable() bool
Servable reports whether the association can run.
type EdgeHeader ¶
EdgeHeader is one header entry. Key is inserted with initial capitalization when a function omits it.
type EdgeInvoker ¶
type EdgeInvoker interface {
InvokeEdge(ctx context.Context, versionLogicalID string, timeout time.Duration, payload []byte) ([]byte, error)
}
EdgeInvoker invokes a Lambda@Edge function version through the runner's real function path.
type EdgeOrigin ¶
type EdgeOrigin struct {
Custom *EdgeCustomOrigin `json:"custom,omitempty"`
S3 *EdgeS3Origin `json:"s3,omitempty"`
}
EdgeOrigin is the origin object for origin events.
type EdgeOutcome ¶
type EdgeOutcome struct {
Request *EdgeRequest
Response *EdgeResponse
Logs []string
}
EdgeOutcome is one function execution: it returned a request, a generated response, or (for response events) a replaced response.
type EdgeRequest ¶
type EdgeRequest struct {
ClientIP string `json:"clientIp"`
Headers map[string][]EdgeHeader `json:"headers"`
Method string `json:"method"`
Querystring string `json:"querystring"`
URI string `json:"uri"`
Body *EdgeBody `json:"body,omitempty"`
// Origin is the origin a returned request switches to. CloudFront resolves
// the domain again and forwards to that origin.
Origin *EdgeOrigin `json:"origin,omitempty"`
}
EdgeRequest is the request object.
type EdgeResponse ¶
type EdgeResponse struct {
Headers map[string][]EdgeHeader `json:"headers"`
Status EdgeStatus `json:"status"`
StatusDescription string `json:"statusDescription,omitempty"`
Body *EdgeBody `json:"body,omitempty"`
// BodyEncoding is the flat encoding beside a string body:
// "If you include body in the response object but omit bodyEncoding,
// CloudFront treats the body as text."
BodyEncoding string `json:"bodyEncoding,omitempty"`
}
EdgeResponse is the response object. Status is documented as a string and renders as one; a numeric status is also accepted because handlers commonly return one.
type EdgeS3Origin ¶
type EdgeS3Origin struct {
AuthMethod string `json:"authMethod"`
Region string `json:"region"`
DomainName string `json:"domainName"`
Path string `json:"path"`
}
EdgeS3Origin is an S3 origin description.
type EdgeStatus ¶
type EdgeStatus int
EdgeStatus is an HTTP status that CloudFront documents as a string: "status: 'HTTP status code (string)'". UnmarshalJSON accepts a JSON string or number; MarshalJSON always writes the string form the events carry.
func (EdgeStatus) MarshalJSON ¶
func (s EdgeStatus) MarshalJSON() ([]byte, error)
MarshalJSON writes the string form.
func (*EdgeStatus) UnmarshalJSON ¶
func (s *EdgeStatus) UnmarshalJSON(raw []byte) error
UnmarshalJSON accepts "200" and 200.
type EdgeValidationError ¶
EdgeValidationError is an invalid object or body a function returned. CloudFront answers 502 for an incorrectly formed response: https://repost.aws/knowledge-center/lambda-edge-500-errors
func (*EdgeValidationError) Error ¶
func (e *EdgeValidationError) Error() string
type EncryptionEntity ¶
type EncryptionEntity struct {
PublicKeyID string `json:"publicKeyId"`
ProviderID string `json:"providerId"`
FieldPatterns []string `json:"fieldPatterns,omitempty"`
}
EncryptionEntity is one EncryptionEntities entry: a public key, a provider name and the field name patterns it encrypts.
type Event ¶
type Event struct {
Version string `json:"version"`
Context EventContext `json:"context"`
Viewer Viewer `json:"viewer"`
Request *EventRequest `json:"request,omitempty"`
Response *EventResponse `json:"response,omitempty"`
}
Event is the CloudFront Functions event object, version 1.0.
type EventContext ¶
type EventContext struct {
DistributionDomainName string `json:"distributionDomainName,omitempty"`
DistributionID string `json:"distributionId"`
EventType string `json:"eventType"`
RequestID string `json:"requestId"`
}
EventContext is the context object CloudFront passes to a function.
type EventRequest ¶
type EventRequest struct {
Method string `json:"method"`
URI string `json:"uri"`
Querystring QueryString `json:"querystring"`
Headers map[string]HeaderValue `json:"headers"`
Cookies map[string]HeaderValue `json:"cookies"`
}
EventRequest is the request object.
type EventResponse ¶
type EventResponse struct {
StatusCode int `json:"statusCode"`
StatusDescription string `json:"statusDescription,omitempty"`
Headers map[string]HeaderValue `json:"headers"`
Cookies map[string]CookieValue `json:"cookies"`
Body *ResponseBody `json:"body,omitempty"`
}
EventResponse is the response object. The body is optional: when it is absent the origin body is returned unchanged.
type Executor ¶
type Executor struct {
// NodePath is the Node executable. An empty value means "node" on PATH.
NodePath string
// Timeout bounds one function execution. CloudFront's own limit is 1 ms;
// the local executor uses a watchdog because Node and process startup cost
// more than the CloudFront CPU budget.
Timeout time.Duration
}
Executor runs CloudFront Function code in a fresh Node vm context. The code is the exact FunctionCode string from the template.
func NewExecutor ¶
func NewExecutor() *Executor
NewExecutor returns an executor with the default Node path and timeout.
func (*Executor) Available ¶
Available reports whether the executor can find Node.js. The runner checks it before serving a distribution that has CloudFront Functions.
func (*Executor) Execute ¶
func (e *Executor) Execute(ctx context.Context, function *Function, event *Event) (*FunctionResult, error)
Execute runs one event through the function.
func (*Executor) ExecuteBatch ¶
func (e *Executor) ExecuteBatch( ctx context.Context, function *Function, events []*Event, ) ([]*FunctionResult, error)
ExecuteBatch runs events in one Node process, each in a fresh vm context. The first function error stops the batch; CloudFront would return a 503 for that request, and the caller must not treat the remaining cases as passes.
type FieldLevelEncryptionConfig ¶
type FieldLevelEncryptionConfig struct {
LogicalID string `json:"logicalId"`
Stack string `json:"stack"`
Comment string `json:"comment,omitempty"`
ContentTypeProfileConfig *ContentTypeProfileConfig `json:"contentTypeProfileConfig,omitempty"`
QueryArgProfileConfig *QueryArgProfileConfig `json:"queryArgProfileConfig,omitempty"`
Reported []string `json:"reported,omitempty"`
Refusals []string `json:"refusals,omitempty"`
}
FieldLevelEncryptionConfig is one AWS::CloudFront::FieldLevelEncryptionConfig.
func (*FieldLevelEncryptionConfig) Servable ¶
func (c *FieldLevelEncryptionConfig) Servable() bool
Servable reports whether the configuration can be applied.
type FieldLevelEncryptionOutcome ¶
type FieldLevelEncryptionOutcome struct {
// Blocked is a request CloudFront refuses instead of forwarding.
Blocked bool
// Status is the status a blocked request returns.
Status int
// Reason names why the request was blocked.
Reason string
// Applied reports that the body was encrypted.
Applied bool
}
FieldLevelEncryptionOutcome reports what the edge did with one request body.
type FieldLevelEncryptionProfile ¶
type FieldLevelEncryptionProfile struct {
LogicalID string `json:"logicalId"`
Stack string `json:"stack"`
Name string `json:"name,omitempty"`
Comment string `json:"comment,omitempty"`
Entities []EncryptionEntity `json:"entities,omitempty"`
Reported []string `json:"reported,omitempty"`
Refusals []string `json:"refusals,omitempty"`
}
FieldLevelEncryptionProfile is one AWS::CloudFront::FieldLevelEncryptionProfile.
func (*FieldLevelEncryptionProfile) Servable ¶
func (p *FieldLevelEncryptionProfile) Servable() bool
Servable reports whether the profile can be applied.
type ForwardingMode ¶
type ForwardingMode string
ForwardingMode is the CloudFront behavior for headers, cookies or query strings.
const ( ForwardNone ForwardingMode = "none" ForwardWhitelist ForwardingMode = "whitelist" ForwardAll ForwardingMode = "all" ForwardAllExcept ForwardingMode = "allExcept" )
type FrameOptions ¶
FrameOptions is a X-Frame-Options setting.
type Function ¶
type Function struct {
LogicalID string `json:"logicalId"`
Stack string `json:"stack"`
Name string `json:"name,omitempty"`
Comment string `json:"comment,omitempty"`
Runtime string `json:"runtime"`
Code string `json:"-"`
CodeBytes int `json:"codeBytes"`
// KeyValueStore names the AWS::CloudFront::KeyValueStore the function reads.
KeyValueStore string `json:"keyValueStore,omitempty"`
Reported []string `json:"reported,omitempty"`
Refusals []string `json:"refusals,omitempty"`
// contains filtered or unexported fields
}
Function is one AWS::CloudFront::Function. Code is the exact FunctionCode string from the template.
func (*Function) AttachStore ¶
func (f *Function) AttachStore(store *KeyValueStore)
AttachStore binds the materialized key value store to the function.
func (*Function) Store ¶
func (f *Function) Store() *KeyValueStore
Store returns the function's key value store, if any.
type FunctionError ¶
type FunctionError struct {
Function string
EventType string
Code string
Message string
Logs []string
}
FunctionError is a function that threw, returned an invalid object or could not run. CloudFront turns it into a 503; the gateway must not pass the request through.
func (*FunctionError) Error ¶
func (e *FunctionError) Error() string
type FunctionResult ¶
type FunctionResult struct {
Kind ResultKind
Request *EventRequest
Response *EventResponse
Logs []string
}
FunctionResult is one validated function execution.
type Gateway ¶
type Gateway struct {
Distribution *Distribution
Topology *Topology
Origins map[string]Origin
Executor *Executor
Now func() time.Time
RequestID func() string
Logf func(format string, args ...any)
MaxBody int64
// Cache stores origin responses for this distribution.
Cache *Cache
// EdgeInvoker invokes Lambda@Edge function versions through the runner's
// real function path.
EdgeInvoker EdgeInvoker
// ViewerCountry is the run's resolved ISO 3166-1 alpha-2 viewer country.
// An empty value is an undetermined location.
ViewerCountry string
// contains filtered or unexported fields
}
Gateway serves one CloudFront distribution's edge path locally. It selects the cache behavior, runs the viewer-request and viewer-response functions, applies the origin request and response headers policies, and hands origin requests to the Origin implementations.
func NewGateway ¶
func NewGateway( distribution *Distribution, topology *Topology, origins map[string]Origin, executor *Executor, logf func(string, ...any), ) *Gateway
NewGateway builds a gateway. A nil executor uses the default Node executor; a nil origin map leaves every origin without a local implementation, which the gateway reports as a named 503.
func (*Gateway) ServeHTTP ¶
func (g *Gateway) ServeHTTP(writer http.ResponseWriter, request *http.Request)
ServeHTTP runs one viewer request through the distribution's edge path.
func (*Gateway) Stats ¶
func (g *Gateway) Stats() map[string]BehaviorStats
Stats returns a copy of the gateway's per-behavior hit and miss counts.
type GeoRestriction ¶
type GeoRestriction struct {
// Type is none, whitelist or blacklist. CloudFront's API also accepts the
// allowlist/denylist spellings; they are normalized.
Type string `json:"type"`
Locations []string `json:"locations,omitempty"`
}
GeoRestriction is DistributionConfig Restrictions.GeoRestriction.
func (*GeoRestriction) Blocks ¶
func (r *GeoRestriction) Blocks(country string) bool
Blocks reports whether a resolved viewer country is denied by the restriction. An empty country is an undetermined location, which CloudFront serves.
type HeaderForwarding ¶
type HeaderForwarding struct {
Mode ForwardingMode `json:"mode"`
Names []string `json:"names,omitempty"`
CloudFrontHeaders bool `json:"cloudFrontHeaders,omitempty"`
}
HeaderForwarding is a headers config.
type HeaderValue ¶
type HeaderValue struct {
Value string `json:"value"`
MultiValue []HeaderValue `json:"multiValue,omitempty"`
}
HeaderValue is one header, cookie or query string value. MultiValue is set when the request carried the name more than once.
type Invalidation ¶
type Invalidation struct {
ID string `json:"id"`
DistributionID string `json:"distributionId"`
Status string `json:"status"`
CreateTime time.Time `json:"createTime"`
Paths []string `json:"paths"`
CallerReference string `json:"callerReference"`
}
Invalidation is one local invalidation request.
type InvalidationAPI ¶
type InvalidationAPI struct {
// contains filtered or unexported fields
}
InvalidationAPI serves the local CloudFront invalidation API.
func NewInvalidationAPI ¶
func NewInvalidationAPI(now func() time.Time, logf func(string, ...any)) *InvalidationAPI
NewInvalidationAPI builds an empty control-plane API.
func (*InvalidationAPI) Invalidations ¶
func (api *InvalidationAPI) Invalidations() []Invalidation
Invalidations returns a copy of every recorded invalidation, newest first.
func (*InvalidationAPI) Register ¶
func (api *InvalidationAPI) Register(logicalID string, cache *Cache) string
Register makes one distribution's cache reachable by the API.
func (*InvalidationAPI) ServeHTTP ¶
func (api *InvalidationAPI) ServeHTTP(writer http.ResponseWriter, request *http.Request)
ServeHTTP routes one control-plane call.
type InvalidationPathError ¶
type InvalidationPathError struct{ Reason string }
InvalidationPathError reports an invalidation path the API refuses.
func (*InvalidationPathError) Error ¶
func (e *InvalidationPathError) Error() string
type KeyGroup ¶
type KeyGroup struct {
LogicalID string `json:"logicalId"`
Stack string `json:"stack"`
Name string `json:"name,omitempty"`
Comment string `json:"comment,omitempty"`
Items []string `json:"items,omitempty"`
Reported []string `json:"reported,omitempty"`
Refusals []string `json:"refusals,omitempty"`
}
KeyGroup is one AWS::CloudFront::KeyGroup.
type KeyValueStore ¶
type KeyValueStore struct {
LogicalID string `json:"logicalId"`
Stack string `json:"stack"`
Name string `json:"name,omitempty"`
Comment string `json:"comment,omitempty"`
// SourceType is the import source type; CloudFront accepts S3.
SourceType string `json:"sourceType,omitempty"`
// ObjectKey is the S3 object key the import source names.
ObjectKey string `json:"objectKey,omitempty"`
// Values is the materialized store content. The runner fills it from the
// assembly asset before the distribution is served.
Values map[string]string `json:"-"`
// CreatedAt and UpdatedAt are the run's timestamps for meta().
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
Reported []string `json:"reported,omitempty"`
Refusals []string `json:"refusals,omitempty"`
}
KeyValueStore is one AWS::CloudFront::KeyValueStore, materialized from the import source the assembly carries.
func (*KeyValueStore) KeyCount ¶
func (s *KeyValueStore) KeyCount() int
KeyCount returns the number of keys the store holds.
func (*KeyValueStore) Keys ¶
func (s *KeyValueStore) Keys() []string
Keys returns the store's keys in sorted order.
func (*KeyValueStore) LoadImportFile ¶
func (s *KeyValueStore) LoadImportFile(payload []byte, now time.Time) error
LoadImportFile parses the documented key-value pair import file: {"data": [{"key": "...", "value": "..."}]}. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/kvs-with-functions-create-s3-kvp.html
func (*KeyValueStore) Servable ¶
func (s *KeyValueStore) Servable() bool
Servable reports whether the store can be used.
type Origin ¶
type Origin interface {
Fetch(ctx context.Context, request OriginRequest) (OriginResponse, error)
}
Origin is the interface the local runner implements for the S3 emulator origin, the Lambda Function URL origin, and origin groups.
The gateway selects the behavior, runs the viewer-request function and applies the cache and origin request policies before calling the origin. The origin receives the viewer-modified URI without the origin path, the policy- filtered query and headers, and the Host the policy chose. An origin group receives OriginPath empty and is responsible for applying each member's origin path and Host.
type OriginAccessControl ¶
type OriginAccessControl struct {
LogicalID string `json:"logicalId"`
Stack string `json:"stack"`
OriginType string `json:"originType,omitempty"`
SigningBehavior string `json:"signingBehavior,omitempty"`
SigningProtocol string `json:"signingProtocol,omitempty"`
Reported []string `json:"reported,omitempty"`
}
OriginAccessControl is an AWS::CloudFront::OriginAccessControl. The gateway reports it; an S3 origin applies its access model and a Function URL origin reproduces its SigV4 signing.
type OriginFunc ¶
type OriginFunc func(ctx context.Context, request OriginRequest) (OriginResponse, error)
OriginFunc adapts a function to Origin.
func (OriginFunc) Fetch ¶
func (f OriginFunc) Fetch(ctx context.Context, request OriginRequest) (OriginResponse, error)
Fetch calls the function.
type OriginGroup ¶
type OriginGroup struct {
ID string `json:"id"`
Members []string `json:"members"`
FailoverStatusCodes []int `json:"failoverStatusCodes,omitempty"`
Refusals []string `json:"refusals,omitempty"`
}
OriginGroup is an origin group. The gateway implements the documented failover behavior from the members and status codes.
type OriginGroupMember ¶
OriginGroupMember is one member of an origin group. OriginPath and Host are the member origin's own values: CloudFront applies each member's origin path and Host when it fails over, while the group request itself carries neither.
type OriginGroupOrigin ¶
type OriginGroupOrigin struct {
GroupID string
Members []OriginGroupMember
FailoverStatusCodes []int
}
OriginGroupOrigin implements CloudFront origin failover.
AWS documents the failover rules: CloudFront routes a request to the primary member; when the primary returns a status code configured in FailoverCriteria, or CloudFront fails to connect (when 503 is configured) or the primary times out (when 504 is configured), it retries the secondary member with that member's origin path and Host. GET and HEAD always fail over; OPTIONS fails over only when the behavior caches OPTIONS in CachedMethods, and other methods go to the primary only.
func NewOriginGroupOrigin ¶
func NewOriginGroupOrigin(groupID string, members []OriginGroupMember, codes []int) *OriginGroupOrigin
NewOriginGroupOrigin builds a group with a primary and a secondary member.
func (*OriginGroupOrigin) Fetch ¶
func (g *OriginGroupOrigin) Fetch(ctx context.Context, request OriginRequest) (OriginResponse, error)
Fetch sends the request to the primary member and fails over to the secondary when CloudFront would.
func (*OriginGroupOrigin) FetchStream ¶
func (g *OriginGroupOrigin) FetchStream(ctx context.Context, request OriginRequest) (StreamResponse, error)
FetchStream sends the request to the primary member and fails over to the secondary when CloudFront would. A buffered member's complete response is wrapped as a single-chunk stream so the gateway has one streaming path.
type OriginKind ¶
type OriginKind string
OriginKind names what the origin points at.
const ( OriginS3 OriginKind = "s3" OriginCustom OriginKind = "custom" )
type OriginRequest ¶
type OriginRequest struct {
// OriginID is the behavior's TargetOriginId: an origin id or an origin
// group id.
OriginID string
// Method is the viewer method; a viewer-request function cannot change it.
Method string
// URI is the viewer path after the viewer-request function and the
// distribution's DefaultRootObject. It never contains OriginPath.
URI string
// OriginPath is the selected origin's OriginPath. It is empty for an origin
// group because a group's failover member can have a different path.
OriginPath string
// Query is the policy-filtered raw query string, without a leading "?".
Query string
// Host is the origin Host. A managed policy that forwards the viewer Host
// puts the viewer host here; otherwise it is the single origin's domain. It
// is empty for an origin group that does not forward the viewer Host.
Host string
// Header carries the policy-filtered headers. Host and Cookie are set on
// Host and in this map respectively, never duplicated.
Header http.Header
Body []byte
// Range is the viewer Range header. CloudFront forwards Range to the
// origin without putting it in a cache or origin request policy; the S3
// origin applies it and other origins ignore it.
Range string
// CachedMethods is the selected behavior's CachedMethods. An origin group
// fails over an OPTIONS request only when OPTIONS is listed:
// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/high_availability_origin_failover.html
CachedMethods []string
// SuppressS3ResponseOverrides is set when the behavior's managed origin
// request policy makes CloudFront drop response-content-type,
// response-content-disposition and response-content-encoding from an S3
// origin request. Only an S3 origin applies it.
SuppressS3ResponseOverrides bool
// ViewerIP is the viewer address the gateway observed.
ViewerIP string
// RequestID is the CloudFront request id used in the function event.
RequestID string
// DistributionID is the local distribution id used in the function event.
DistributionID string
}
OriginRequest is what the gateway sends to an origin.
func (OriginRequest) Path ¶
func (r OriginRequest) Path() string
Path returns the path an origin should request: OriginPath followed by URI.
type OriginRequestPolicy ¶
type OriginRequestPolicy struct {
Headers HeaderForwarding `json:"headers"`
Cookies CookieForwarding `json:"cookies"`
QueryStrings QueryForwarding `json:"queryStrings"`
}
OriginRequestPolicy is the origin request policy definition.
type OriginResponse ¶
type OriginResponse struct {
StatusCode int
StatusDescription string
Header http.Header
Body []byte
}
OriginResponse is an origin response.
type OriginUnavailableError ¶
type OriginUnavailableError struct {
}
OriginUnavailableError reports an origin the local gateway cannot reach or serve. The gateway answers 503 with this reason; it never fakes the origin.
func (*OriginUnavailableError) Error ¶
func (e *OriginUnavailableError) Error() string
Error names the origin and the reason it is unavailable locally.
func (*OriginUnavailableError) Unwrap ¶
func (e *OriginUnavailableError) Unwrap() error
Unwrap lets callers test errors.Is(err, ErrOriginUnavailable).
type Policy ¶
type Policy struct {
Kind PolicyKind `json:"kind"`
ID string `json:"id"`
LogicalID string `json:"logicalId,omitempty"`
Managed bool `json:"managed,omitempty"`
Cache *CachePolicy `json:"cache,omitempty"`
OriginRequest *OriginRequestPolicy `json:"originRequest,omitempty"`
ResponseHeaders *ResponseHeadersPolicy `json:"responseHeaders,omitempty"`
Reported []string `json:"reported,omitempty"`
Refusals []string `json:"refusals,omitempty"`
}
Policy is a cache, origin request or response headers policy. A managed policy is pinned by id; a custom policy keeps its logical id.
type PolicyKind ¶
type PolicyKind string
PolicyKind names a CloudFront policy resource kind.
const ( PolicyCache PolicyKind = "cache" PolicyOriginRequest PolicyKind = "origin-request" PolicyResponseHeaders PolicyKind = "response-headers" )
type PublicKey ¶
type PublicKey struct {
LogicalID string `json:"logicalId"`
Stack string `json:"stack"`
Name string `json:"name,omitempty"`
Comment string `json:"comment,omitempty"`
EncodedKey string `json:"-"`
ID string `json:"keyPairId"`
Reported []string `json:"reported,omitempty"`
Refusals []string `json:"refusals,omitempty"`
// contains filtered or unexported fields
}
PublicKey is one AWS::CloudFront::PublicKey. ID is the local Key-Pair-Id the runner assigns deterministically from the assembly, printed by plan and session describe so an application can sign.
type QueryArgProfile ¶
type QueryArgProfile struct {
QueryArg string `json:"queryArg"`
ProfileID string `json:"profileId"`
}
QueryArgProfile is one QueryArgProfiles entry.
type QueryArgProfileConfig ¶
type QueryArgProfileConfig struct {
ForwardWhenQueryArgProfileIsUnknown bool `json:"forwardWhenQueryArgProfileIsUnknown"`
Profiles []QueryArgProfile `json:"profiles,omitempty"`
}
QueryArgProfileConfig maps the fle-profile query argument to a profile.
type QueryForwarding ¶
type QueryForwarding struct {
Mode ForwardingMode `json:"mode"`
Names []string `json:"names,omitempty"`
}
QueryForwarding is a query strings config.
type QueryString ¶
type QueryString struct {
Values map[string]HeaderValue `json:"-"`
Raw string `json:"-"`
}
QueryString is either the object form or the documented string shortcut a function may return.
func (QueryString) MarshalJSON ¶
func (q QueryString) MarshalJSON() ([]byte, error)
MarshalJSON writes the string form when a function returned one, otherwise the object form.
func (*QueryString) UnmarshalJSON ¶
func (q *QueryString) UnmarshalJSON(raw []byte) error
UnmarshalJSON accepts the object form and the documented string shortcut.
type ReferrerPolicy ¶
ReferrerPolicy is a Referrer-Policy setting.
type Resource ¶
type Resource struct {
Type string
Properties json.RawMessage
}
Resource is one template resource: its CloudFormation type and Properties.
type ResponseBody ¶
ResponseBody is a replaced viewer-response body.
type ResponseHeadersPolicy ¶
type ResponseHeadersPolicy struct {
CORS *CORSConfig `json:"cors,omitempty"`
Security *SecurityHeaders `json:"security,omitempty"`
Custom []CustomHeader `json:"custom,omitempty"`
Remove []string `json:"remove,omitempty"`
Reported []string `json:"reported,omitempty"`
}
ResponseHeadersPolicy is the response headers policy definition.
type ResultKind ¶
type ResultKind string
ResultKind says which object a function returned.
const ( ResultRequest ResultKind = "request" ResultResponse ResultKind = "response" )
type S3Origin ¶
type S3Origin struct {
OriginAccessIdentity string `json:"originAccessIdentity,omitempty"`
}
S3Origin is an S3OriginConfig the gateway reports.
type SecurityHeaders ¶
type SecurityHeaders struct {
ContentSecurityPolicy *ContentSecurityPolicy `json:"contentSecurityPolicy,omitempty"`
ContentTypeOptions *ContentTypeOptions `json:"contentTypeOptions,omitempty"`
FrameOptions *FrameOptions `json:"frameOptions,omitempty"`
ReferrerPolicy *ReferrerPolicy `json:"referrerPolicy,omitempty"`
StrictTransportSecurity *StrictTransportSecurity `json:"strictTransportSecurity,omitempty"`
XSSProtection *XSSProtection `json:"xssProtection,omitempty"`
}
SecurityHeaders is a response headers policy security section.
type StreamOrigin ¶
type StreamOrigin interface {
Origin
// FetchStream returns the response status and headers as soon as the origin
// produces them, with a body that yields each payload chunk.
FetchStream(ctx context.Context, request OriginRequest) (StreamResponse, error)
}
StreamOrigin is an origin that can return a response before its body is complete. The gateway forwards each chunk to the viewer as it arrives and caches the object only when the response completes.
type StreamResponse ¶
type StreamResponse struct {
StatusCode int
StatusDescription string
Header http.Header
Body io.ReadCloser
// Chunked reports that the origin used HTTP/1.1 chunked transfer encoding.
// CloudFront forwards such an object to the viewer as it receives it and
// caches it in chunked format.
// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html
Chunked bool
}
StreamResponse is an origin response whose body is still arriving.
type StrictTransportSecurity ¶
type StrictTransportSecurity struct {
MaxAgeSeconds int `json:"maxAgeSeconds"`
IncludeSubdomains bool `json:"includeSubdomains,omitempty"`
Preload bool `json:"preload,omitempty"`
Override bool `json:"override"`
}
StrictTransportSecurity is a Strict-Transport-Security setting.
type Template ¶
Template is one CloudFormation stack template the topology reader scans. The runner passes the same stacks it derived the Lambda surface from, so the distribution is read from the app's own cloud assembly rather than from a second hand-written route table.
type Topology ¶
type Topology struct {
Distributions []*Distribution `json:"distributions"`
Functions []*Function `json:"functions,omitempty"`
Policies []*Policy `json:"policies,omitempty"`
OriginAccessControls []*OriginAccessControl `json:"originAccessControls,omitempty"`
PublicKeys []*PublicKey `json:"publicKeys,omitempty"`
KeyGroups []*KeyGroup `json:"keyGroups,omitempty"`
KeyValueStores []*KeyValueStore `json:"keyValueStores,omitempty"`
FieldLevelEncryptionConfigs []*FieldLevelEncryptionConfig `json:"fieldLevelEncryptionConfigs,omitempty"`
FieldLevelEncryptionProfiles []*FieldLevelEncryptionProfile `json:"fieldLevelEncryptionProfiles,omitempty"`
// contains filtered or unexported fields
}
Topology is everything the gateway derived from the cloud assembly.
func ParseTemplates ¶
ParseTemplates reads every CloudFront distribution, function and referenced policy in the templates. A malformed template is an error; a valid template using a feature the gateway does not implement becomes a refusal on the distribution, reported by the caller instead of being ignored.
func (*Topology) Distribution ¶
func (t *Topology) Distribution(logicalID string) (*Distribution, bool)
Distribution returns one distribution by qualified logical id.
func (*Topology) FieldLevelEncryptionConfig ¶
func (t *Topology) FieldLevelEncryptionConfig(logicalID string) (*FieldLevelEncryptionConfig, bool)
FieldLevelEncryptionConfig returns one FLE configuration by qualified logical id.
func (*Topology) FieldLevelEncryptionProfile ¶
func (t *Topology) FieldLevelEncryptionProfile(logicalID string) (*FieldLevelEncryptionProfile, bool)
FieldLevelEncryptionProfile returns one FLE profile by qualified logical id.
func (*Topology) KeyValueStore ¶
func (t *Topology) KeyValueStore(logicalID string) (*KeyValueStore, bool)
KeyValueStore returns one CloudFront key value store by qualified logical id.
type TrustedKeyGroups ¶
type TrustedKeyGroups struct {
Enabled bool `json:"enabled"`
Items []string `json:"items,omitempty"`
}
TrustedKeyGroups is the behavior's TrustedKeyGroups setting.