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,
};
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_cloudfront as cloudfront
from aws_cdk import aws_lambda as lambda_
from aws_cdk.interfaces import aws_cloudfront as interfaces_cloudfront
# function_ref: interfaces_cloudfront.IFunctionRef
# key_group_ref: interfaces_cloudfront.IKeyGroupRef
# 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_ref
)],
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_ref],
trusted_signers=["trustedSigners"],
viewer_protocol_policy=cloudfront.ViewerProtocolPolicy.HTTPS_ONLY
)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.cloudfront.*;
import software.amazon.awscdk.services.lambda.*;
import software.amazon.awscdk.interfaces.cloudfront.*;
IFunctionRef functionRef;
IKeyGroupRef keyGroupRef;
Version version;
Behavior behavior = Behavior.builder()
.allowedMethods(CloudFrontAllowedMethods.GET_HEAD)
.cachedMethods(CloudFrontAllowedCachedMethods.GET_HEAD)
.compress(false)
.defaultTtl(Duration.minutes(30))
.forwardedValues(ForwardedValuesProperty.builder()
.queryString(false)
// the properties below are optional
.cookies(CookiesProperty.builder()
.forward("forward")
// the properties below are optional
.whitelistedNames(List.of("whitelistedNames"))
.build())
.headers(List.of("headers"))
.queryStringCacheKeys(List.of("queryStringCacheKeys"))
.build())
.functionAssociations(List.of(FunctionAssociation.builder()
.eventType(FunctionEventType.VIEWER_REQUEST)
.function(functionRef)
.build()))
.isDefaultBehavior(false)
.lambdaFunctionAssociations(List.of(LambdaFunctionAssociation.builder()
.eventType(LambdaEdgeEventType.ORIGIN_REQUEST)
.lambdaFunction(version)
// the properties below are optional
.includeBody(false)
.build()))
.maxTtl(Duration.minutes(30))
.minTtl(Duration.minutes(30))
.pathPattern("pathPattern")
.trustedKeyGroups(List.of(keyGroupRef))
.trustedSigners(List.of("trustedSigners"))
.viewerProtocolPolicy(ViewerProtocolPolicy.HTTPS_ONLY)
.build();
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.CloudFront;
using Amazon.CDK.AWS.Lambda;
using Amazon.CDK.Interfaces.CloudFront;
IFunctionRef functionRef;
IKeyGroupRef keyGroupRef;
Version version;
var behavior = new Behavior {
AllowedMethods = CloudFrontAllowedMethods.GET_HEAD,
CachedMethods = CloudFrontAllowedCachedMethods.GET_HEAD,
Compress = false,
DefaultTtl = Duration.Minutes(30),
ForwardedValues = new ForwardedValuesProperty {
QueryString = false,
// the properties below are optional
Cookies = new CookiesProperty {
Forward = "forward",
// the properties below are optional
WhitelistedNames = new [] { "whitelistedNames" }
},
Headers = new [] { "headers" },
QueryStringCacheKeys = new [] { "queryStringCacheKeys" }
},
FunctionAssociations = new [] { new FunctionAssociation {
EventType = FunctionEventType.VIEWER_REQUEST,
Function = functionRef
} },
IsDefaultBehavior = false,
LambdaFunctionAssociations = new [] { new LambdaFunctionAssociation {
EventType = LambdaEdgeEventType.ORIGIN_REQUEST,
LambdaFunction = version,
// the properties below are optional
IncludeBody = false
} },
MaxTtl = Duration.Minutes(30),
MinTtl = Duration.Minutes(30),
PathPattern = "pathPattern",
TrustedKeyGroups = new [] { keyGroupRef },
TrustedSigners = new [] { "trustedSigners" },
ViewerProtocolPolicy = ViewerProtocolPolicy.HTTPS_ONLY
};
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
var functionRef IFunctionRef
var keyGroupRef IKeyGroupRef
var version Version
behavior := &Behavior{
AllowedMethods: awscdk.Aws_cloudfront.CloudFrontAllowedMethods_GET_HEAD,
CachedMethods: awscdk.*Aws_cloudfront.CloudFrontAllowedCachedMethods_GET_HEAD,
Compress: jsii.Boolean(false),
DefaultTtl: cdk.Duration_Minutes(jsii.Number(30)),
ForwardedValues: &ForwardedValuesProperty{
QueryString: jsii.Boolean(false),
// the properties below are optional
Cookies: &CookiesProperty{
Forward: jsii.String("forward"),
// the properties below are optional
WhitelistedNames: []*string{
jsii.String("whitelistedNames"),
},
},
Headers: []*string{
jsii.String("headers"),
},
QueryStringCacheKeys: []*string{
jsii.String("queryStringCacheKeys"),
},
},
FunctionAssociations: []FunctionAssociation{
&FunctionAssociation{
EventType: awscdk.*Aws_cloudfront.FunctionEventType_VIEWER_REQUEST,
Function: functionRef,
},
},
IsDefaultBehavior: jsii.Boolean(false),
LambdaFunctionAssociations: []LambdaFunctionAssociation{
&LambdaFunctionAssociation{
EventType: awscdk.*Aws_cloudfront.LambdaEdgeEventType_ORIGIN_REQUEST,
LambdaFunction: version,
// the properties below are optional
IncludeBody: jsii.Boolean(false),
},
},
MaxTtl: cdk.Duration_*Minutes(jsii.Number(30)),
MinTtl: cdk.Duration_*Minutes(jsii.Number(30)),
PathPattern: jsii.String("pathPattern"),
TrustedKeyGroups: []IKeyGroupRef{
keyGroupRef,
},
TrustedSigners: []*string{
jsii.String("trustedSigners"),
},
ViewerProtocolPolicy: awscdk.*Aws_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