Skip to content

Instantly share code, notes, and snippets.

@tonyOreglia
Created November 21, 2022 08:25
Show Gist options
  • Select an option

  • Save tonyOreglia/193ed4362b5b023a4c9d068c53781ca1 to your computer and use it in GitHub Desktop.

Select an option

Save tonyOreglia/193ed4362b5b023a4c9d068c53781ca1 to your computer and use it in GitHub Desktop.
CFDistribution:
#checkov:skip=CKV_AWS_68: "For demo purposes and to reduce cost, no WAF is configured"
Type: 'AWS::CloudFront::Distribution'
DependsOn:
- CFOriginAccessIdentity
Properties:
DistributionConfig:
Origins:
- DomainName: !GetAtt S3Bucket.RegionalDomainName
Id: myS3Origin
S3OriginConfig:
OriginAccessIdentity: !Sub 'origin-access-identity/cloudfront/${CFOriginAccessIdentity}'
Enabled: 'true'
DefaultRootObject: index.html
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
- OPTIONS
TargetOriginId: myS3Origin
CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6 # CachingOptimized
OriginRequestPolicyId: 88a5eaf4-2fd4-4709-b370-b4c650ea3fcf # CORS-S3Origin
ViewerProtocolPolicy: redirect-to-https
PriceClass: PriceClass_All
Logging:
Bucket: !GetAtt LoggingBucket.RegionalDomainName
Prefix: 'cloudfront-access-logs'
Aliases:
- tonycodes.com
ViewerCertificate:
SslSupportMethod: sni-only
MinimumProtocolVersion: TLSv1.2_2021
AcmCertificateArn: !Ref TonyCodesDNSCertificate
TonyCodesDNSCertificate:
Type: AWS::CertificateManager::Certificate
Properties:
DomainName: tonycodes.com
DomainValidationOptions:
- DomainName: tonycodes.com
HostedZoneId: Z05106722AGOCZ1FSFD3D
ValidationMethod: DNS
TonyCodesDNSAliasRecord:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneId: Z05106722AGOCZ1FSFD3D
RecordSets:
- Name: tonycodes.com
Type: A
AliasTarget:
HostedZoneId: Z2FDTNDATAQYW2
DNSName: !GetAtt
- CFDistribution
- DomainName
- Name: tonycodes.com
Type: AAAA
AliasTarget:
HostedZoneId: Z2FDTNDATAQYW2
DNSName: !GetAtt
- CFDistribution
- DomainName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment