Behavior Struct
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 cdk from 'aws-cdk-lib';
import { aws_cloudfront as cloudfront } from 'aws-cdk-lib';
import { aws_lambda as lambda } from 'aws-cdk-lib';
import { aws_cloudfront as interfaces_cloudfront } from 'aws-cdk-lib/interfaces';
declare const functionRef: interfaces_cloudfront.IFunctionRef;
declare const keyGroupRef: interfaces_cloudfront.IKeyGroupRef;
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: functionRef,
}],
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: [keyGroupRef],
trustedSigners: ['trustedSigners'],
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.HTTPS_ONLY,
};
Properties
allowedMethodsCloudFrontAllowedMethodsallowed_methodsCloudFrontAllowedMethodsallowedMethodsCloudFrontAllowedMethodsAllowedMethodsCloudFrontAllowedMethodsAllowedMethodsCloudFrontAllowedMethods= GET_HEAD#cachedMethodsCloudFrontAllowedCachedMethodscached_methodsCloudFrontAllowedCachedMethodscachedMethodsCloudFrontAllowedCachedMethodsCachedMethodsCloudFrontAllowedCachedMethodsCachedMethodsCloudFrontAllowedCachedMethods= GET_HEAD#defaultTtlDurationdefault_ttlDurationdefaultTtlDurationDefaultTtlDurationDefaultTtlDuration= 86400 (1 day)#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.
forwardedValuesCfnDistribution.ForwardedValuesPropertyforwarded_valuesForwardedValuesPropertyforwardedValuesForwardedValuesPropertyForwardedValuesForwardedValuesPropertyForwardedValuesForwardedValuesProperty= none (no cookies - no headers)#functionAssociationsFunctionAssociation[]function_associationstyping.List[FunctionAssociation]functionAssociationsList<FunctionAssociation>FunctionAssociationsFunctionAssociation[]FunctionAssociations*[]FunctionAssociation= no functions will be invoked#isDefaultBehaviorbooleanis_default_behaviorboolisDefaultBehaviorBooleanIsDefaultBehaviorboolIsDefaultBehavior*bool#You must specify exactly one default distribution per CloudFront distribution. The default behavior is allowed to omit the "path" property.
lambdaFunctionAssociationsLambdaFunctionAssociation[]lambda_function_associationstyping.List[LambdaFunctionAssociation]lambdaFunctionAssociationsList<LambdaFunctionAssociation>LambdaFunctionAssociationsLambdaFunctionAssociation[]LambdaFunctionAssociations*[]LambdaFunctionAssociation= No lambda function associated#maxTtlDurationmax_ttlDurationmaxTtlDurationMaxTtlDurationMaxTtlDuration= Duration.seconds(31536000) (one …#default
Default: Duration.seconds(31536000) (one year)
Required for all non-default behaviors. (The default behavior implicitly has "*" as the path pattern. )
trustedKeyGroupsIKeyGroupRef[]trusted_key_groupstyping.List[IKeyGroupRef]trustedKeyGroupsList<IKeyGroupRef>TrustedKeyGroupsIKeyGroupRef[]TrustedKeyGroups*[]IKeyGroupRef= no KeyGroups are associated with…#default
Default: no KeyGroups are associated with cache behavior
trustedSignersstring[]trusted_signerstyping.List[str]trustedSignersList<String>TrustedSignersstring[]TrustedSigners*[]*stringdeprecated#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)
viewerProtocolPolicyViewerProtocolPolicyviewer_protocol_policyViewerProtocolPolicyviewerProtocolPolicyViewerProtocolPolicyViewerProtocolPolicyViewerProtocolPolicyViewerProtocolPolicyViewerProtocolPolicy= the distribution wide viewer pro…#default
Default: the distribution wide viewer protocol policy will be used