Skip to content

Instantly share code, notes, and snippets.

@qswitcher
Last active July 25, 2018 01:52
Show Gist options
  • Save qswitcher/05153fcce86f26b2b64af857888cb879 to your computer and use it in GitHub Desktop.
Save qswitcher/05153fcce86f26b2b64af857888cb879 to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: 2010-09-09
Resources:
DeployBucket:
Type: 'AWS::S3::Bucket'
Properties:
# Technically we don't need the S3 bucket configured
# as a website, but I included it for the sake of completion.
WebsiteConfiguration:
IndexDocument: index.html
Distribution:
Type: "AWS::CloudFront::Distribution"
Properties:
DistributionConfig:
Origins:
-
# Use the DeployBucket as the CDN origin
DomainName: !GetAtt DeployBucket.DomainName
Id: !Ref DeployBucket
S3OriginConfig:
OriginAccessIdentity: ''
DefaultRootObject: index.html
Enabled: true
# Configure the caching behavior for our CDN
DefaultCacheBehavior:
MinTTL: 86400 # 1 day
MaxTTL: 31536000 # 1 year
ForwardedValues:
QueryString: true
TargetOriginId: !Ref DeployBucket
ViewerProtocolPolicy: "redirect-to-https" # we want to force HTTPS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment