i'm trying to create a cachePolicy that forward all ( cookies, querystrings and headers ) and acctualy doesn't cache annything at all:
Type: AWS::CloudFront::CachePolicy
Properties:
CachePolicyConfig:
Comment: Cache Policy
DefaultTTL: 0
MaxTTL: 0
MinTTL: 0
Name: !Sub ${AWS::StackName}-cache-policy
ParametersInCacheKeyAndForwardedToOrigin:
CookiesConfig:
CookieBehavior: all
EnableAcceptEncodingBrotli: true
EnableAcceptEncodingGzip: true
HeadersConfig:
HeaderBehavior: whitelist
Headers:
- "*"
QueryStringsConfig:
QueryStringBehavior: all
and my OriginRequestPolicy:
OriginRequestPolicy:
Type: AWS::CloudFront::OriginRequestPolicy
Properties:
OriginRequestPolicyConfig:
Name: !Sub ${AWS::StackName}-origin-request
CookiesConfig:
CookieBehavior: all
HeadersConfig:
HeaderBehavior: allViewer
QueryStringsConfig:
QueryStringBehavior: all
but whem i try to upload the stack, i get a generic error:
The following resource(s) failed to create: [OriginRequestPolicy, CachePolicy]. Rollback requested by user. OriginRequestPolicy CREATE_FAILED Resource creation cancelled CachePolicy CREATE_FAILED Invalid request provided: AWS::CloudFront::CachePolicy
what am i missing?
obs: I can't only create an AWS::CloudFront::OriginRequestPolicy
cause it's seems that i can only have a OriginRequestPolicy if alredy exists a cacheRequestPolicy first..
This error seems to be caused by the name property. For me, having a '.' in the name produces the error.
Nothing is stated regarding this in the documentation unfortunately: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-cachepolicy-cachepolicyconfig.html#cfn-cloudfront-cachepolicy-cachepolicyconfig-name
This works:
AWSTemplateFormatVersion: 2010-09-09
Resources:
CachePolicy:
Type: AWS::CloudFront::CachePolicy
Properties:
CachePolicyConfig:
DefaultTTL: 1
MaxTTL: 1
MinTTL: 1
Name: test
ParametersInCacheKeyAndForwardedToOrigin:
CookiesConfig:
CookieBehavior: all
EnableAcceptEncodingBrotli: false
EnableAcceptEncodingGzip: false
HeadersConfig:
HeaderBehavior: none
QueryStringsConfig:
QueryStringBehavior: all
Hyphen in the name works:
AWSTemplateFormatVersion: 2010-09-09
Resources:
CachePolicy:
Type: AWS::CloudFront::CachePolicy
Properties:
CachePolicyConfig:
DefaultTTL: 1
MaxTTL: 1
MinTTL: 1
Name: test-id
ParametersInCacheKeyAndForwardedToOrigin:
CookiesConfig:
CookieBehavior: all
EnableAcceptEncodingBrotli: false
EnableAcceptEncodingGzip: false
HeadersConfig:
HeaderBehavior: none
QueryStringsConfig:
QueryStringBehavior: all
Does not work:
AWSTemplateFormatVersion: 2010-09-09
Resources:
CachePolicy:
Type: AWS::CloudFront::CachePolicy
Properties:
CachePolicyConfig:
DefaultTTL: 1
MaxTTL: 1
MinTTL: 1
Name: test-id.test
ParametersInCacheKeyAndForwardedToOrigin:
CookiesConfig:
CookieBehavior: all
EnableAcceptEncodingBrotli: false
EnableAcceptEncodingGzip: false
HeadersConfig:
HeaderBehavior: none
QueryStringsConfig:
QueryStringBehavior: all