Last active
November 11, 2022 08:05
-
-
Save paulswail/c04f471bddc276844dea85735f378813 to your computer and use it in GitHub Desktop.
Configuring a CloudFront distribution in front of API Gateway (Serverless Framework)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resources: | |
Resources: | |
APIGatewayFront: | |
Type: AWS::CloudFront::Distribution | |
Properties: | |
DistributionConfig: | |
Enabled: true | |
IPV6Enabled: true | |
HttpVersion: http2 | |
Comment: CDN in front of API Gateway | |
Origins: | |
- Id: APIGWOrigin | |
DomainName: ${ApiId}.execute-api.${aws:region}.amazonaws.com # TODO fix this to properly reference API ID of API Gateway in same service | |
OriginPath: "/" | |
CustomOriginConfig: | |
HTTPSPort: 443 | |
OriginProtocolPolicy: https-only | |
DefaultCacheBehavior: | |
AllowedMethods: ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"] | |
CachedMethods: ["GET", "HEAD", "OPTIONS"] | |
ForwardedValues: | |
Headers: | |
- Access-Control-Request-Headers | |
- Access-Control-Request-Method | |
- Origin | |
- Authorization | |
QueryString: true | |
TargetOriginId: APIGWOrigin | |
ViewerProtocolPolicy: https-only | |
Compress: true | |
DefaultTTL: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment