interface BehaviorOptions
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.CloudFront.BehaviorOptions |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awscloudfront#BehaviorOptions |
Java | software.amazon.awscdk.services.cloudfront.BehaviorOptions |
Python | aws_cdk.aws_cloudfront.BehaviorOptions |
TypeScript (source) | aws-cdk-lib » aws_cloudfront » BehaviorOptions |
Options for creating a new behavior.
Example
// Adding an existing Lambda@Edge function created in a different stack
// to a CloudFront distribution.
declare const s3Bucket: s3.Bucket;
const functionVersion = lambda.Version.fromVersionArn(this, 'Version', 'arn:aws:lambda:us-east-1:123456789012:function:functionName:1');
new cloudfront.Distribution(this, 'distro', {
defaultBehavior: {
origin: new origins.S3Origin(s3Bucket),
edgeLambdas: [
{
functionVersion,
eventType: cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
},
],
},
});
Properties
Name | Type | Description |
---|---|---|
origin | IOrigin | The origin that you want CloudFront to route requests to when they match this behavior. |
allowed | Allowed | HTTP methods to allow for this behavior. |
cache | ICache | The cache policy for this behavior. |
cached | Cached | HTTP methods to cache for this behavior. |
compress? | boolean | Whether you want CloudFront to automatically compress certain files for this cache behavior. |
edge | Edge [] | The Lambda@Edge functions to invoke before serving the contents. |
function | Function [] | The CloudFront functions to invoke before serving the contents. |
origin | IOrigin | The origin request policy for this behavior. |
realtime | IRealtime | The real-time log configuration to be attached to this cache behavior. |
response | IResponse | The response headers policy for this behavior. |
smooth | boolean | Set this to true to indicate you want to distribute media files in the Microsoft Smooth Streaming format using this behavior. |
trusted | IKey [] | A list of Key Groups that CloudFront can use to validate signed URLs or signed cookies. |
viewer | Viewer | The protocol that viewers can use to access the files controlled by this behavior. |
origin
Type:
IOrigin
The origin that you want CloudFront to route requests to when they match this behavior.
allowedMethods?
Type:
Allowed
(optional, default: AllowedMethods.ALLOW_GET_HEAD)
HTTP methods to allow for this behavior.
cachePolicy?
Type:
ICache
(optional, default: CachePolicy.CACHING_OPTIMIZED)
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.
See also: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/controlling-the-cache-key.html.
cachedMethods?
Type:
Cached
(optional, default: CachedMethods.CACHE_GET_HEAD)
HTTP methods to cache for this behavior.
compress?
Type:
boolean
(optional, default: true)
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.
edgeLambdas?
Type:
Edge
[]
(optional, default: no Lambda functions will be invoked)
The Lambda@Edge functions to invoke before serving the contents.
See also: https://aws.amazon.com/lambda/edge
functionAssociations?
Type:
Function
[]
(optional, default: no functions will be invoked)
The CloudFront functions to invoke before serving the contents.
originRequestPolicy?
Type:
IOrigin
(optional, default: none)
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.
realtimeLogConfig?
Type:
IRealtime
(optional, default: none)
The real-time log configuration to be attached to this cache behavior.
responseHeadersPolicy?
Type:
IResponse
(optional, default: none)
The response headers policy for this behavior.
The response headers policy determines which headers are included in responses
smoothStreaming?
Type:
boolean
(optional, default: false)
Set this to true to indicate you want to distribute media files in the Microsoft Smooth Streaming format using this behavior.
trustedKeyGroups?
Type:
IKey
[]
(optional, default: no KeyGroups are associated with cache behavior)
A list of Key Groups that CloudFront can use to validate signed URLs or signed cookies.
See also: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html
viewerProtocolPolicy?
Type:
Viewer
(optional, default: ViewerProtocolPolicy.ALLOW_ALL)
The protocol that viewers can use to access the files controlled by this behavior.