Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions cdn/dovetail-cdn/cloudfront.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ Resources:
CloudFrontCachePolicy:
Type: AWS::CloudFront::CachePolicy
Properties:
# The headers, cookies, and query strings that are included in the
# CACHE KEY (CachePolicyConfig) are also included in requests that
# CloudFront sends to the origin.
CachePolicyConfig:
Comment: !Sub Policy for ${AWS::StackName}
DefaultTTL: 86400
Expand All @@ -212,12 +215,19 @@ Resources:
EnableAcceptEncodingBrotli: false
EnableAcceptEncodingGzip: false
HeadersConfig:
HeaderBehavior: none
HeaderBehavior: whitelist
Headers:
- Origin
- Access-Control-Request-Headers
- Access-Control-Request-Method
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need access-control-allow-origin?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wait, this is for the caching, not what headers to support, I see this is what AWS recommends for caching OPTIONS requests for an s3 bucket:
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-cors

QueryStringsConfig:
QueryStringBehavior: none
CloudFrontOriginRequestPolicy:
Type: AWS::CloudFront::OriginRequestPolicy
Properties:
# The headers, cookies, and query strings that are included in the
# CACHE KEY (CachePolicyConfig) are also included in requests that
# CloudFront sends to the origin.
OriginRequestPolicyConfig:
Comment: !Sub Policy for ${AWS::StackName}
CookiesConfig:
Expand Down Expand Up @@ -331,8 +341,8 @@ Resources:
CacheBehaviors:
- Fn::If:
- HasRegion1
- AllowedMethods: [HEAD, GET]
CachedMethods: [HEAD, GET]
- AllowedMethods: [HEAD, GET, OPTIONS]
CachedMethods: [HEAD, GET, OPTIONS]
CachePolicyId: !Ref CloudFrontCachePolicy
Compress: false
FunctionAssociations:
Expand All @@ -349,8 +359,8 @@ Resources:
- !Ref AWS::NoValue
- Fn::If:
- HasRegion2
- AllowedMethods: [HEAD, GET]
CachedMethods: [HEAD, GET]
- AllowedMethods: [HEAD, GET, OPTIONS]
CachedMethods: [HEAD, GET, OPTIONS]
CachePolicyId: !Ref CloudFrontCachePolicy
Compress: false
FunctionAssociations:
Expand All @@ -367,8 +377,8 @@ Resources:
- !Ref AWS::NoValue
- Fn::If:
- HasRegion3
- AllowedMethods: [HEAD, GET]
CachedMethods: [HEAD, GET]
- AllowedMethods: [HEAD, GET, OPTIONS]
CachedMethods: [HEAD, GET, OPTIONS]
CachePolicyId: !Ref CloudFrontCachePolicy
Compress: false
FunctionAssociations:
Expand Down
9 changes: 9 additions & 0 deletions spire/templates/apps/dovetail-cdn-arranger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ Resources:
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Properties:
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- "*"
AllowedMethods:
- GET
- HEAD
AllowedOrigins:
- "*"
LifecycleConfiguration:
Rules:
- ExpirationInDays: 1
Expand Down