How do I use this in a template I found no examples: * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-distributionconfig.html#cfn-cloudfront-distribution-distributionconfig-cachebehaviors * https://docs.amazonaws.cn/en_us/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-cachebehavior.html
I have a DefaultCacheBehavior defined and now I want to add addtional behaviours.
I tried this but I get an error:
.....
CFDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Enabled: 'true'
Comment: 'sdlkfjsdlkfjsldkfj'
PriceClass: 'PriceClass_All'
IPV6Enabled: true
DefaultRootObject: index.html
Origins:
-
Id: Origin01 # arbitrary identifier
S3OriginConfig: {}
DomainName: 'mydomain.blhblhb.blhb.com'
ViewerCertificate:
AcmCertificateArn: 'my-cer-id'
SslSupportMethod: sni-only
DefaultCacheBehavior:
TargetOriginId: Origin01
ViewerProtocolPolicy: redirect-to-https
Compress: true
MinTTL: 0
DefaultTTL: 3600
MaxTTL: 31536000
AllowedMethods:
- GET
- HEAD
CachedMethods:
- GET
- HEAD
ForwardedValues:
QueryString: 'false'
Headers:
- Origin
- CloudFront-Viewer-Country
Cookies:
Forward: none
# Tried adding this but no workie
CacheBehaviors:
CacheBehavior:
PathPattern: '/somepath/*'
TargetOriginId: Origin01
ViewerProtocolPolicy: redirect-to-https
Compress: true
MinTTL: 0
DefaultTTL: 3600
MaxTTL: 31536000
AllowedMethods:
- GET
- HEAD
CachedMethods:
- GET
- HEAD
ForwardedValues:
QueryString: 'false'
Headers:
- Origin
- CloudFront-Viewer-Country
Cookies:
Forward: none
LambdaFunctionAssociations:
-
EventType: origin-request
LambdaFunctionARN: !Ref MyLambda.Version
I get error:
Property validation failure: [Value of property {/DistributionConfig/CacheBehaviors} does not match type {Array}]