Behavior¶
-
class
aws_cdk.aws_cloudfront.
Behavior
(*, allowed_methods=None, cached_methods=None, compress=None, default_ttl=None, forwarded_values=None, function_associations=None, is_default_behavior=None, lambda_function_associations=None, max_ttl=None, min_ttl=None, path_pattern=None, trusted_key_groups=None, trusted_signers=None, viewer_protocol_policy=None)¶ Bases:
object
A CloudFront behavior wrapper.
- Parameters
allowed_methods (
Optional
[CloudFrontAllowedMethods
]) – The method this CloudFront distribution responds do. Default: GET_HEADcached_methods (
Optional
[CloudFrontAllowedCachedMethods
]) – Which methods are cached by CloudFront by default. Default: GET_HEADcompress (
Optional
[bool
]) – If CloudFront should automatically compress some content types. Default: truedefault_ttl (
Optional
[Duration
]) – The default amount of time CloudFront will cache an object. This value applies only when your custom origin does not add HTTP headers, such as Cache-Control max-age, Cache-Control s-maxage, and Expires to objects. Default: 86400 (1 day)forwarded_values (
Optional
[ForwardedValuesProperty
]) – The values CloudFront will forward to the origin when making a request. Default: none (no cookies - no headers)function_associations (
Optional
[Sequence
[FunctionAssociation
]]) – The CloudFront functions to invoke before serving the contents. Default: - no functions will be invokedis_default_behavior (
Optional
[bool
]) – If this behavior is the default behavior for the distribution. You must specify exactly one default distribution per CloudFront distribution. The default behavior is allowed to omit the “path” property.lambda_function_associations (
Optional
[Sequence
[LambdaFunctionAssociation
]]) – Declares associated lambda@edge functions for this distribution behaviour. Default: No lambda function associatedmax_ttl (
Optional
[Duration
]) – The max amount of time you want objects to stay in the cache before CloudFront queries your origin. Default: Duration.seconds(31536000) (one year)min_ttl (
Optional
[Duration
]) – The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin.path_pattern (
Optional
[str
]) – The path this behavior responds to. Required for all non-default behaviors. (The default behavior implicitly has “*” as the path pattern. )trusted_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 behaviortrusted_signers (
Optional
[Sequence
[str
]]) – (deprecated) Trusted signers is how CloudFront allows you to serve private content. The signers are the account IDs that are allowed to sign cookies/presigned URLs for this distribution. If you pass a non empty value, all requests for this behavior must be signed (no public access will be allowed)viewer_protocol_policy (
Optional
[ViewerProtocolPolicy
]) – The viewer policy for this behavior. Default: - the distribution wide viewer protocol policy will be used
- ExampleMetadata
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_cloudfront as cloudfront import aws_cdk.aws_lambda as lambda_ import aws_cdk.core as cdk # function_: cloudfront.Function # key_group: cloudfront.KeyGroup # version: lambda.Version behavior = cloudfront.Behavior( allowed_methods=cloudfront.CloudFrontAllowedMethods.GET_HEAD, cached_methods=cloudfront.CloudFrontAllowedCachedMethods.GET_HEAD, compress=False, default_ttl=cdk.Duration.minutes(30), forwarded_values=cloudfront.CfnDistribution.ForwardedValuesProperty( query_string=False, # the properties below are optional cookies=cloudfront.CfnDistribution.CookiesProperty( forward="forward", # the properties below are optional whitelisted_names=["whitelistedNames"] ), headers=["headers"], query_string_cache_keys=["queryStringCacheKeys"] ), function_associations=[cloudfront.FunctionAssociation( event_type=cloudfront.FunctionEventType.VIEWER_REQUEST, function=function_ )], is_default_behavior=False, lambda_function_associations=[cloudfront.LambdaFunctionAssociation( event_type=cloudfront.LambdaEdgeEventType.ORIGIN_REQUEST, lambda_function=version, # the properties below are optional include_body=False )], max_ttl=cdk.Duration.minutes(30), min_ttl=cdk.Duration.minutes(30), path_pattern="pathPattern", trusted_key_groups=[key_group], trusted_signers=["trustedSigners"], viewer_protocol_policy=cloudfront.ViewerProtocolPolicy.HTTPS_ONLY )
Attributes
-
allowed_methods
¶ The method this CloudFront distribution responds do.
- Default
GET_HEAD
- Return type
Optional
[CloudFrontAllowedMethods
]
-
cached_methods
¶ Which methods are cached by CloudFront by default.
- Default
GET_HEAD
- Return type
Optional
[CloudFrontAllowedCachedMethods
]
-
compress
¶ If CloudFront should automatically compress some content types.
- Default
true
- Return type
Optional
[bool
]
-
default_ttl
¶ The default amount of time CloudFront will cache an object.
This value applies only when your custom origin does not add HTTP headers, such as Cache-Control max-age, Cache-Control s-maxage, and Expires to objects.
- Default
86400 (1 day)
- Return type
Optional
[Duration
]
-
forwarded_values
¶ The values CloudFront will forward to the origin when making a request.
- Default
none (no cookies - no headers)
- Return type
Optional
[ForwardedValuesProperty
]
-
function_associations
¶ The CloudFront functions to invoke before serving the contents.
- Default
no functions will be invoked
- Return type
Optional
[List
[FunctionAssociation
]]
-
is_default_behavior
¶ If this behavior is the default behavior for the distribution.
You must specify exactly one default distribution per CloudFront distribution. The default behavior is allowed to omit the “path” property.
- Return type
Optional
[bool
]
-
lambda_function_associations
¶ Declares associated lambda@edge functions for this distribution behaviour.
- Default
No lambda function associated
- Return type
Optional
[List
[LambdaFunctionAssociation
]]
-
max_ttl
¶ The max amount of time you want objects to stay in the cache before CloudFront queries your origin.
- Default
Duration.seconds(31536000) (one year)
- Return type
Optional
[Duration
]
-
min_ttl
¶ The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin.
- Return type
Optional
[Duration
]
-
path_pattern
¶ The path this behavior responds to.
Required for all non-default behaviors. (The default behavior implicitly has “*” as the path pattern. )
- Return type
Optional
[str
]
-
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
]]
-
trusted_signers
¶ (deprecated) Trusted signers is how CloudFront allows you to serve private content.
The signers are the account IDs that are allowed to sign cookies/presigned URLs for this distribution.
If you pass a non empty value, all requests for this behavior must be signed (no public access will be allowed)
- Deprecated
We recommend using trustedKeyGroups instead of trustedSigners.
- Stability
deprecated
- Return type
Optional
[List
[str
]]
-
viewer_protocol_policy
¶ The viewer policy for this behavior.
- Default
the distribution wide viewer protocol policy will be used
- Return type
Optional
[ViewerProtocolPolicy
]