Skip to content

Instantly share code, notes, and snippets.

@joshuabalduff
Created February 4, 2019 13:42
Show Gist options
  • Save joshuabalduff/6d55433d4bd974ec54972764f416ef51 to your computer and use it in GitHub Desktop.
Save joshuabalduff/6d55433d4bd974ec54972764f416ef51 to your computer and use it in GitHub Desktop.
Amazon CloudFront Distribution Resource with Custom Origin
AWSTemplateFormatVersion: '2010-09-09'
Resources:
myDistribution:
Type: 'AWS::CloudFront::Distribution'
Properties:
DistributionConfig:
Origins:
- DomainName: www.example.com
Id: myCustomOrigin
CustomOriginConfig:
HTTPPort: '80'
HTTPSPort: '443'
OriginProtocolPolicy: http-only
Enabled: 'true'
Comment: Somecomment
DefaultRootObject: index.html
Logging:
IncludeCookies: 'true'
Bucket: mylogs.s3.amazonaws.com
Prefix: myprefix
Aliases:
- mysite.example.com
- "*.yoursite.example.com"
DefaultCacheBehavior:
TargetOriginId: myCustomOrigin
SmoothStreaming: 'false'
ForwardedValues:
QueryString: 'false'
Cookies:
Forward: all
TrustedSigners:
- 1234567890EX
- 1234567891EX
ViewerProtocolPolicy: allow-all
CustomErrorResponses:
- ErrorCode: '404'
ResponsePagePath: "/error-pages/404.html"
ResponseCode: '200'
ErrorCachingMinTTL: '30'
PriceClass: PriceClass_200
Restrictions:
GeoRestriction:
RestrictionType: whitelist
Locations:
- AQ
- CV
ViewerCertificate:
CloudFrontDefaultCertificate: 'true'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment