Skip to content

Instantly share code, notes, and snippets.

@kalda341
Created April 10, 2020 23:17
Show Gist options
  • Select an option

  • Save kalda341/45eaf0937c7ca1a8d97d6425cfbb707a to your computer and use it in GitHub Desktop.

Select an option

Save kalda341/45eaf0937c7ca1a8d97d6425cfbb707a to your computer and use it in GitHub Desktop.
ember_distribution = template.add_resource(Distribution(
'EmberDistribution',
DistributionConfig=DistributionConfig(
Enabled=True,
DefaultRootObject='index.html',
# Allow us to have nice urls (without #)
CustomErrorResponses=[
CustomErrorResponse(
ErrorCachingMinTTL=5,
ErrorCode=404,
ResponseCode=200,
ResponsePagePath='/index.html'
)
],
Aliases=[
domain_name
],
Origins=[
Origin(
DomainName=bucket_domain_name,
Id='S3Origin',
S3OriginConfig=S3OriginConfig()
)
],
DefaultCacheBehavior=DefaultCacheBehavior(
Compress=True,
AllowedMethods=[
'GET',
'HEAD',
'OPTIONS'
],
ForwardedValues=ForwardedValues(
QueryString=False
),
# How long CloudFront caches for. When the origin adds a Cache-Control max-age directive:
# CloudFront caching depends on the values of the CloudFront minimum TTL and maximum TTL,
# and the Cache-Control max-age directive:
# Minimum TTL < max-age < maximum TTL:
# CloudFront caches objects for the value of the Cache-Control max-age directive.
# max-age < minimum TTL:
# CloudFront caches objects for the value of the CloudFront minimum TTL.
# max-age > maximum TTL:
# CloudFront caches objects for the value of the CloudFront maximum TTL.
MaxTTL=3600,
DefaultTTL=300,
MinTTL=0,
TargetOriginId='S3Origin',
ViewerProtocolPolicy='redirect-to-https',
),
ViewerCertificate=ViewerCertificate(
AcmCertificateArn=Ref(certificate),
SslSupportMethod='sni-only'
),
HttpVersion='http2'
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment