interface Behavior
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.CloudFront.Behavior |
Java | software.amazon.awscdk.services.cloudfront.Behavior |
Python | aws_cdk.aws_cloudfront.Behavior |
TypeScript (source) | @aws-cdk/aws-cloudfront » Behavior |
A CloudFront behavior wrapper.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cloudfront from '@aws-cdk/aws-cloudfront';
import * as lambda from '@aws-cdk/aws-lambda';
import * as cdk from '@aws-cdk/core';
declare const function_: cloudfront.Function;
declare const keyGroup: cloudfront.KeyGroup;
declare const version: lambda.Version;
const behavior: cloudfront.Behavior = {
allowedMethods: cloudfront.CloudFrontAllowedMethods.GET_HEAD,
cachedMethods: cloudfront.CloudFrontAllowedCachedMethods.GET_HEAD,
compress: false,
defaultTtl: cdk.Duration.minutes(30),
forwardedValues: {
queryString: false,
// the properties below are optional
cookies: {
forward: 'forward',
// the properties below are optional
whitelistedNames: ['whitelistedNames'],
},
headers: ['headers'],
queryStringCacheKeys: ['queryStringCacheKeys'],
},
functionAssociations: [{
eventType: cloudfront.FunctionEventType.VIEWER_REQUEST,
function: function_,
}],
isDefaultBehavior: false,
lambdaFunctionAssociations: [{
eventType: cloudfront.LambdaEdgeEventType.ORIGIN_REQUEST,
lambdaFunction: version,
// the properties below are optional
includeBody: false,
}],
maxTtl: cdk.Duration.minutes(30),
minTtl: cdk.Duration.minutes(30),
pathPattern: 'pathPattern',
trustedKeyGroups: [keyGroup],
trustedSigners: ['trustedSigners'],
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.HTTPS_ONLY,
};
Properties
Name | Type | Description |
---|---|---|
allowed | Cloud | The method this CloudFront distribution responds do. |
cached | Cloud | Which methods are cached by CloudFront by default. |
compress? | boolean | If CloudFront should automatically compress some content types. |
default | Duration | The default amount of time CloudFront will cache an object. |
forwarded | Forwarded | The values CloudFront will forward to the origin when making a request. |
function | Function [] | The CloudFront functions to invoke before serving the contents. |
is | boolean | If this behavior is the default behavior for the distribution. |
lambda | Lambda [] | Declares associated lambda@edge functions for this distribution behaviour. |
max | Duration | The max amount of time you want objects to stay in the cache before CloudFront queries your origin. |
min | Duration | The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin. |
path | string | The path this behavior responds to. |
trusted | IKey [] | A list of Key Groups that CloudFront can use to validate signed URLs or signed cookies. |
trusted | string[] | Trusted signers is how CloudFront allows you to serve private content. |
viewer | Viewer | The viewer policy for this behavior. |
allowedMethods?
Type:
Cloud
(optional, default: GET_HEAD)
The method this CloudFront distribution responds do.
cachedMethods?
Type:
Cloud
(optional, default: GET_HEAD)
Which methods are cached by CloudFront by default.
compress?
Type:
boolean
(optional, default: true)
If CloudFront should automatically compress some content types.
defaultTtl?
Type:
Duration
(optional, default: 86400 (1 day))
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.
forwardedValues?
Type:
Forwarded
(optional, default: none (no cookies - no headers))
The values CloudFront will forward to the origin when making a request.
functionAssociations?
Type:
Function
[]
(optional, default: no functions will be invoked)
The CloudFront functions to invoke before serving the contents.
isDefaultBehavior?
Type:
boolean
(optional)
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.
lambdaFunctionAssociations?
Type:
Lambda
[]
(optional, default: No lambda function associated)
Declares associated lambda@edge functions for this distribution behaviour.
maxTtl?
Type:
Duration
(optional, default: Duration.seconds(31536000) (one year))
The max amount of time you want objects to stay in the cache before CloudFront queries your origin.
minTtl?
Type:
Duration
(optional)
The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin.
pathPattern?
Type:
string
(optional)
The path this behavior responds to.
Required for all non-default behaviors. (The default behavior implicitly has "*" as the path pattern. )
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.
trustedSigners?
⚠️ Deprecated: - We recommend using trustedKeyGroups instead of trustedSigners.
Type:
string[]
(optional)
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)
viewerProtocolPolicy?
Type:
Viewer
(optional, default: the distribution wide viewer protocol policy will be used)
The viewer policy for this behavior.