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
allowedMethodsoptionalCloudFrontAllowedMethodsallowed_methodsoptionalCloudFrontAllowedMethodsallowedMethodsoptionalCloudFrontAllowedMethodsAllowedMethodsoptionalCloudFrontAllowedMethodsAllowedMethodsoptionalCloudFrontAllowedMethods= GET_HEAD#cachedMethodsoptionalCloudFrontAllowedCachedMethodscached_methodsoptionalCloudFrontAllowedCachedMethodscachedMethodsoptionalCloudFrontAllowedCachedMethodsCachedMethodsoptionalCloudFrontAllowedCachedMethodsCachedMethodsoptionalCloudFrontAllowedCachedMethods= GET_HEAD#compressoptionalbooleancompressoptionalboolcompressoptionalBooleanCompressoptionalboolCompressoptional*bool= true#defaultTtloptionalDurationdefault_ttloptionalDurationdefaultTtloptionalDurationDefaultTtloptionalDurationDefaultTtloptionalDuration#Default: 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.
forwardedValuesoptionalCfnDistribution.ForwardedValuesPropertyforwarded_valuesoptionalForwardedValuesPropertyforwardedValuesoptionalForwardedValuesPropertyForwardedValuesoptionalForwardedValuesPropertyForwardedValuesoptionalForwardedValuesProperty#Default: none (no cookies - no headers)
functionAssociationsoptionalFunctionAssociation[]function_associationsoptionaltyping.List[FunctionAssociation]functionAssociationsoptionalList<FunctionAssociation>FunctionAssociationsoptionalFunctionAssociation[]FunctionAssociationsoptional*[]FunctionAssociation#Default: no functions will be invoked
isDefaultBehavioroptionalbooleanis_default_behavioroptionalboolisDefaultBehavioroptionalBooleanIsDefaultBehavioroptionalboolIsDefaultBehavioroptional*bool#You must specify exactly one default distribution per CloudFront distribution. The default behavior is allowed to omit the "path" property.
lambdaFunctionAssociationsoptionalLambdaFunctionAssociation[]lambda_function_associationsoptionaltyping.List[LambdaFunctionAssociation]lambdaFunctionAssociationsoptionalList<LambdaFunctionAssociation>LambdaFunctionAssociationsoptionalLambdaFunctionAssociation[]LambdaFunctionAssociationsoptional*[]LambdaFunctionAssociation#Default: No lambda function associated
maxTtloptionalDurationmax_ttloptionalDurationmaxTtloptionalDurationMaxTtloptionalDurationMaxTtloptionalDuration#Default: Duration.seconds(31536000) (one year)
minTtloptionalDurationmin_ttloptionalDurationminTtloptionalDurationMinTtloptionalDurationMinTtloptionalDuration#pathPatternoptionalstringpath_patternoptionalstrpathPatternoptionalStringPathPatternoptionalstringPathPatternoptional*string#Required for all non-default behaviors. (The default behavior implicitly has "*" as the path pattern. )
trustedKeyGroupsoptionalIKeyGroupRef[]trusted_key_groupsoptionaltyping.List[IKeyGroupRef]trustedKeyGroupsoptionalList<IKeyGroupRef>TrustedKeyGroupsoptionalIKeyGroupRef[]TrustedKeyGroupsoptional*[]IKeyGroupRef#Default: no KeyGroups are associated with cache behavior
trustedSignersoptionalstring[]trusted_signersoptionaltyping.List[str]trustedSignersoptionalList<String>TrustedSignersoptionalstring[]TrustedSignersoptional*[]*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)
viewerProtocolPolicyoptionalViewerProtocolPolicyviewer_protocol_policyoptionalViewerProtocolPolicyviewerProtocolPolicyoptionalViewerProtocolPolicyViewerProtocolPolicyoptionalViewerProtocolPolicyViewerProtocolPolicyoptionalViewerProtocolPolicy#Default: the distribution wide viewer protocol policy will be used