BehaviorOptions¶
-
class
aws_cdk.aws_cloudfront.
BehaviorOptions
(*, allowed_methods=None, cached_methods=None, cache_policy=None, compress=None, edge_lambdas=None, function_associations=None, origin_request_policy=None, response_headers_policy=None, smooth_streaming=None, trusted_key_groups=None, viewer_protocol_policy=None, origin)¶ Bases:
aws_cdk.aws_cloudfront.AddBehaviorOptions
Options for creating a new behavior.
- Parameters
allowed_methods (
Optional
[AllowedMethods
]) – HTTP methods to allow for this behavior. Default: AllowedMethods.ALLOW_GET_HEADcached_methods (
Optional
[CachedMethods
]) – HTTP methods to cache for this behavior. Default: CachedMethods.CACHE_GET_HEADcache_policy (
Optional
[ICachePolicy
]) – The cache policy for this behavior. The cache policy determines what values are included in the cache key, and the time-to-live (TTL) values for the cache. Default: CachePolicy.CACHING_OPTIMIZEDcompress (
Optional
[bool
]) – Whether you want CloudFront to automatically compress certain files for this cache behavior. See https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-file-types for file types CloudFront will compress. Default: trueedge_lambdas (
Optional
[Sequence
[EdgeLambda
]]) – The Lambda@Edge functions to invoke before serving the contents. Default: - no Lambda functions will be invokedfunction_associations (
Optional
[Sequence
[FunctionAssociation
]]) – The CloudFront functions to invoke before serving the contents. Default: - no functions will be invokedorigin_request_policy (
Optional
[IOriginRequestPolicy
]) – The origin request policy for this behavior. The origin request policy determines which values (e.g., headers, cookies) are included in requests that CloudFront sends to the origin. Default: - noneresponse_headers_policy (
Optional
[IResponseHeadersPolicy
]) – The response headers policy for this behavior. The response headers policy determines which headers are included in responses Default: - nonesmooth_streaming (
Optional
[bool
]) – Set this to true to indicate you want to distribute media files in the Microsoft Smooth Streaming format using this behavior. Default: falsetrusted_key_groups (
Optional
[Sequence
[IKeyGroup
]]) – A list of Key Groups that CloudFront can use to validate signed URLs or signed cookies. Default: - no KeyGroups are associated with cache behaviorviewer_protocol_policy (
Optional
[ViewerProtocolPolicy
]) – The protocol that viewers can use to access the files controlled by this behavior. Default: ViewerProtocolPolicy.ALLOW_ALLorigin (
IOrigin
) – The origin that you want CloudFront to route requests to when they match this behavior.
- ExampleMetadata
infused
Example:
# Adding an existing Lambda@Edge function created in a different stack # to a CloudFront distribution. # s3_bucket: s3.Bucket function_version = lambda_.Version.from_version_arn(self, "Version", "arn:aws:lambda:us-east-1:123456789012:function:functionName:1") cloudfront.Distribution(self, "distro", default_behavior=cloudfront.BehaviorOptions( origin=origins.S3Origin(s3_bucket), edge_lambdas=[cloudfront.EdgeLambda( function_version=function_version, event_type=cloudfront.LambdaEdgeEventType.VIEWER_REQUEST ) ] ) )
Attributes
-
allowed_methods
¶ HTTP methods to allow for this behavior.
- Default
AllowedMethods.ALLOW_GET_HEAD
- Return type
Optional
[AllowedMethods
]
-
cache_policy
¶ The cache policy for this behavior.
The cache policy determines what values are included in the cache key, and the time-to-live (TTL) values for the cache.
- Default
CachePolicy.CACHING_OPTIMIZED
- See
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/controlling-the-cache-key.html.
- Return type
Optional
[ICachePolicy
]
-
cached_methods
¶ HTTP methods to cache for this behavior.
- Default
CachedMethods.CACHE_GET_HEAD
- Return type
Optional
[CachedMethods
]
-
compress
¶ Whether you want CloudFront to automatically compress certain files for this cache behavior.
See https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-file-types for file types CloudFront will compress.
- Default
true
- Return type
Optional
[bool
]
-
edge_lambdas
¶ The Lambda@Edge functions to invoke before serving the contents.
- Default
no Lambda functions will be invoked
- See
- Return type
Optional
[List
[EdgeLambda
]]
-
function_associations
¶ The CloudFront functions to invoke before serving the contents.
- Default
no functions will be invoked
- Return type
Optional
[List
[FunctionAssociation
]]
-
origin
¶ The origin that you want CloudFront to route requests to when they match this behavior.
- Return type
-
origin_request_policy
¶ The origin request policy for this behavior.
The origin request policy determines which values (e.g., headers, cookies) are included in requests that CloudFront sends to the origin.
- Default
none
- Return type
Optional
[IOriginRequestPolicy
]
-
response_headers_policy
¶ The response headers policy for this behavior.
The response headers policy determines which headers are included in responses
- Default
none
- Return type
Optional
[IResponseHeadersPolicy
]
-
smooth_streaming
¶ Set this to true to indicate you want to distribute media files in the Microsoft Smooth Streaming format using this behavior.
- Default
false
- Return type
Optional
[bool
]
-
trusted_key_groups
¶ A list of Key Groups that CloudFront can use to validate signed URLs or signed cookies.
- Default
no KeyGroups are associated with cache behavior
- See
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html
- Return type
Optional
[List
[IKeyGroup
]]
-
viewer_protocol_policy
¶ The protocol that viewers can use to access the files controlled by this behavior.
- Default
ViewerProtocolPolicy.ALLOW_ALL
- Return type
Optional
[ViewerProtocolPolicy
]