Skip to content

Instantly share code, notes, and snippets.

@richardgrantserverless
Created May 23, 2022 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardgrantserverless/03df6c219550194fc501044b26f1b63f to your computer and use it in GitHub Desktop.
Save richardgrantserverless/03df6c219550194fc501044b26f1b63f to your computer and use it in GitHub Desktop.
resources:
Outputs:
ScreenshotBucket:
Description: "Screenshot bucket name"
Value: ${self:custom.bucket_name}
CloudFrontUrl:
Description: "CloudFront url"
Value: {"Fn::GetAtt": "CloudFrontEndpoint.DomainName"}
Resources:
# Create an endpoint for the S3 bucket in CloudFront
# this configuration basically just sets up a forwarding of requests
# to S3, and forces all traffic to https
CloudFrontEndpoint:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Enabled: True
DefaultCacheBehavior:
TargetOriginId: ScreenshotBucketOrigin
ViewerProtocolPolicy: redirect-to-https
ForwardedValues:
QueryString: True
Origins:
-
Id: ScreenshotBucketOrigin
DomainName: ${self:custom.bucket_name}.s3.amazonaws.com
CustomOriginConfig:
OriginProtocolPolicy: http-only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment