AddBehaviorOptions Struct
Options for adding a new behavior to a Distribution.
Example
// Add a behavior to a Distribution after initial creation.
declare const myBucket: s3.Bucket;
declare const myWebDistribution: cloudfront.Distribution;
myWebDistribution.addBehavior('/images/*.jpg', new origins.S3Origin(myBucket), {
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
});
Properties
allowedMethodsoptionalAllowedMethodsallowed_methodsoptionalAllowedMethodsallowedMethodsoptionalAllowedMethodsAllowedMethodsoptionalAllowedMethodsAllowedMethodsoptionalAllowedMethods= AllowedMethods.ALLOW_GET_HEAD#cachedMethodsoptionalCachedMethodscached_methodsoptionalCachedMethodscachedMethodsoptionalCachedMethodsCachedMethodsoptionalCachedMethodsCachedMethodsoptionalCachedMethods= CachedMethods.CACHE_GET_HEAD#cachePolicyoptionalICachePolicyRefcache_policyoptionalICachePolicyRefcachePolicyoptionalICachePolicyRefCachePolicyoptionalICachePolicyRefCachePolicyoptionalICachePolicyRef= CachePolicy.CACHING_OPTIMIZED#The cache policy determines what values are included in the cache key, and the time-to-live (TTL) values for the cache.
compressoptionalbooleancompressoptionalboolcompressoptionalBooleanCompressoptionalboolCompressoptional*bool= true#See https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-file-types for file types CloudFront will compress.
edgeLambdasoptionalEdgeLambda[]edge_lambdasoptionaltyping.List[EdgeLambda]edgeLambdasoptionalList<EdgeLambda>EdgeLambdasoptionalEdgeLambda[]EdgeLambdasoptional*[]EdgeLambda#Default: no Lambda functions will be invoked
enableGrpcoptionalbooleanenable_grpcoptionalboolenableGrpcoptionalBooleanEnableGrpcoptionalboolEnableGrpcoptional*bool= false#notes
If the enableGrpc is set to true, the following restrictions apply:
- The
allowedMethodsproperty must beAllowedMethods.ALLOW_ALLto include POST method because gRPC only supports POST method. - The
httpVersionproperty must beHttpVersion.HTTP2orHttpVersion.HTTP2_AND_3because gRPC only supports versions including HTTP/2. - The
edgeLambdasproperty can't be specified because gRPC is not supported with Lambda@Edge.
functionAssociationsoptionalFunctionAssociation[]function_associationsoptionaltyping.List[FunctionAssociation]functionAssociationsoptionalList<FunctionAssociation>FunctionAssociationsoptionalFunctionAssociation[]FunctionAssociationsoptional*[]FunctionAssociation#Default: no functions will be invoked
originRequestPolicyoptionalIOriginRequestPolicyReforigin_request_policyoptionalIOriginRequestPolicyReforiginRequestPolicyoptionalIOriginRequestPolicyRefOriginRequestPolicyoptionalIOriginRequestPolicyRefOriginRequestPolicyoptionalIOriginRequestPolicyRef= none#The origin request policy determines which values (e.g., headers, cookies) are included in requests that CloudFront sends to the origin.
realtimeLogConfigoptionalIRealtimeLogConfigRefrealtime_log_configoptionalIRealtimeLogConfigRefrealtimeLogConfigoptionalIRealtimeLogConfigRefRealtimeLogConfigoptionalIRealtimeLogConfigRefRealtimeLogConfigoptionalIRealtimeLogConfigRef= none#responseHeadersPolicyoptionalIResponseHeadersPolicyRefresponse_headers_policyoptionalIResponseHeadersPolicyRefresponseHeadersPolicyoptionalIResponseHeadersPolicyRefResponseHeadersPolicyoptionalIResponseHeadersPolicyRefResponseHeadersPolicyoptionalIResponseHeadersPolicyRef= none#The response headers policy determines which headers are included in responses
smoothStreamingoptionalbooleansmooth_streamingoptionalboolsmoothStreamingoptionalBooleanSmoothStreamingoptionalboolSmoothStreamingoptional*bool= false#trustedKeyGroupsoptionalIKeyGroupRef[]trusted_key_groupsoptionaltyping.List[IKeyGroupRef]trustedKeyGroupsoptionalList<IKeyGroupRef>TrustedKeyGroupsoptionalIKeyGroupRef[]TrustedKeyGroupsoptional*[]IKeyGroupRef#Default: no KeyGroups are associated with cache behavior
viewerProtocolPolicyoptionalViewerProtocolPolicyviewer_protocol_policyoptionalViewerProtocolPolicyviewerProtocolPolicyoptionalViewerProtocolPolicyViewerProtocolPolicyoptionalViewerProtocolPolicyViewerProtocolPolicyoptionalViewerProtocolPolicy#Default: ViewerProtocolPolicy.REDIRECT_TO_HTTPS if the @aws-cdk/aws-cloudfront:defaultViewerProtocolPolicyRedirectToHttps feature flag is enabled, otherwise ViewerProtocolPolicy.ALLOW_ALL