Skip to main content

CloudFrontBehaviorSchema

One rule binding a set of paths to an origin, and deciding everything about how those paths are served.

@group

Resources/CloudFrontDistribution

Index

Properties

optionalallowedMethods

allowedMethods?: readonly [GET, HEAD] | readonly [GET, HEAD, OPTIONS] | readonly [GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE] = ['GET', 'HEAD']

The HTTP methods CloudFront forwards to the origin. See ICloudFrontAllowedMethods.

optionalcachedMethods

cachedMethods?: readonly [GET, HEAD] | readonly [GET, HEAD, OPTIONS] = ['GET', 'HEAD']

The subset of allowedMethods whose responses CloudFront caches. See ICloudFrontCachedMethods.

cachePolicy

cachePolicy: ICloudFrontPolicyReference<Managed-CachingDisabled | Managed-CachingOptimized | Managed-CachingOptimizedForUncompressedObjects | UseOriginCacheControlHeaders | UseOriginCacheControlHeaders-QueryStrings>

Which policy decides the cache key and the TTLs. See ICloudFrontPolicyReference, and ICloudFrontManagedCachePolicy for the managed ones.

optionalcompress

compress?: boolean = true

Whether CloudFront compresses the response for viewers that accept it.

optionalfunctionAssociations

functionAssociations?: CloudFrontFunctionAssociationSchema[] = []

Edge functions to run for this behavior. See CloudFrontFunctionAssociationSchema.

optionaloriginRequestPolicy

originRequestPolicy?: ICloudFrontPolicyReference<Managed-AllViewer | Managed-AllViewerAndCloudFrontHeaders-2022-06 | Managed-AllViewerExceptHostHeader | Managed-CORS-CustomOrigin | Managed-CORS-S3Origin | Managed-HostHeaderOnly | Managed-UserAgentRefererHeaders> | null = null

Which policy decides what reaches the origin, independently of the cache key. null forwards only what the cache policy already selected. See ICloudFrontManagedOriginRequestPolicy for the managed ones.

optionalpathPattern

pathPattern?: string | null = null

The paths this behavior claims, e.g. /api/*. Absent on the default behavior, which claims everything no other behavior did.

optionalresponseHeadersPolicy

responseHeadersPolicy?: ICloudFrontPolicyReference<Managed-CORS-and-SecurityHeadersPolicy | Managed-CORS-With-Preflight | Managed-CORS-with-preflight-and-SecurityHeadersPolicy | Managed-SecurityHeadersPolicy | Managed-SimpleCORS> | null = null

Which policy decides the headers CloudFront adds on the way out - CORS, HSTS, and the app's own content security policy. See ICloudFrontManagedResponseHeadersPolicy for the managed ones.

targetOriginId

targetOriginId: string

The originId or originGroupId serving these paths.

optionalviewerProtocolPolicy

viewerProtocolPolicy?: allow-all | https-only | redirect-to-https = 'redirect-to-https'

What CloudFront does with a plain HTTP request. See ICloudFrontViewerProtocolPolicy.