Skip to content

Commit

Permalink
Update template.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
kevhiggi committed Apr 27, 2022
1 parent f510c93 commit ce85fa4
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,36 @@ Resources:
CanonicalUser: !GetAtt
- OriginAccessIdentity
- S3CanonicalUserId
CloudFrontCachePolicy:
APICloudFrontCachePolicy:
Type: 'AWS::CloudFront::CachePolicy'
Properties:
CachePolicyConfig:
DefaultTTL: 0
MaxTTL: 1
MinTTL: 0
Name: !Sub '${AWS::StackName}-api-cache-policy'
ParametersInCacheKeyAndForwardedToOrigin:
EnableAcceptEncodingGzip: false
HeadersConfig:
HeaderBehavior: whitelist
Headers:
- Access-Control-Request-Headers
- Access-Control-Request-Method
- Origin
- Authorization
- x-api-key
CookiesConfig:
CookieBehavior: none
QueryStringsConfig:
QueryStringBehavior: all
S3CloudFrontCachePolicy:
Type: 'AWS::CloudFront::CachePolicy'
Properties:
CachePolicyConfig:
DefaultTTL: 86400
MaxTTL: 31536000
MinTTL: 1
Name: !Sub '${AWS::StackName}-cache-policy'
Name: !Sub '${AWS::StackName}-s3-cache-policy'
ParametersInCacheKeyAndForwardedToOrigin:
EnableAcceptEncodingGzip: false
HeadersConfig:
Expand All @@ -232,11 +254,10 @@ Resources:
- Access-Control-Request-Method
- Origin
- Authorization
- x-api-key
CookiesConfig:
CookieBehavior: none
QueryStringsConfig:
QueryStringBehavior: all
QueryStringBehavior: none
Distribution:
Type: 'AWS::CloudFront::Distribution'
DependsOn: OriginAccessIdentity
Expand All @@ -246,7 +267,7 @@ Resources:
HttpVersion: http2
DefaultRootObject: index.html
DefaultCacheBehavior:
CachePolicyId: !Ref CloudFrontCachePolicy
CachePolicyId: !Ref S3CloudFrontCachePolicy
AllowedMethods:
- GET
- HEAD
Expand All @@ -264,7 +285,7 @@ Resources:
LambdaFunctionARN: !Ref OriginResponseLambdaFunctionVersion
CacheBehaviors:
- TargetOriginId: APIGW
CachePolicyId: !Ref CloudFrontCachePolicy
CachePolicyId: !Ref APICloudFrontCachePolicy
ViewerProtocolPolicy: redirect-to-https
ResponseHeadersPolicyId: !Ref CloudFrontResourceHeadersPolicy
AllowedMethods:
Expand Down

0 comments on commit ce85fa4

Please sign in to comment.