simplify-cli
Version:
Simplify CLI - Easy Deployment
71 lines (69 loc) • 2.03 kB
YAML
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
Environment:
Type: String
WebsiteS3BucketDomain:
Type: String
HttpRestapiEndpoint:
Type: String
Resources:
S3OriginAccessIdentity:
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: Origin Access for Website with S3Origin
CFDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Origins:
- DomainName: !Ref WebsiteS3BucketDomain
Id: WebsiteS3Origin
S3OriginConfig:
OriginAccessIdentity:
Fn::Join:
- "/"
- - "origin-access-identity"
- "cloudfront"
- !Ref S3OriginAccessIdentity
- DomainName: !Select [2, !Split ["/", !Ref HttpRestapiEndpoint]]
Id: HttpRestapiOrigin
CustomOriginConfig:
HTTPPort: '80'
HTTPSPort: '443'
OriginProtocolPolicy: http-only
CacheBehaviors:
- PathPattern: !Sub "/${Environment}/*"
AllowedMethods:
- GET
- OPTIONS
- HEAD
TargetOriginId: HttpRestapiOrigin
ForwardedValues:
QueryString: 'true'
Cookies:
Forward: all
ViewerProtocolPolicy: allow-all
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
- OPTIONS
TargetOriginId: WebsiteS3Origin
ForwardedValues:
QueryString: 'false'
Cookies:
Forward: none
ViewerProtocolPolicy: allow-all
Enabled: 'true'
Comment: Website Distribution
DefaultRootObject: index.html
ViewerCertificate:
CloudFrontDefaultCertificate: 'true'
Outputs:
Region:
Value: !Ref AWS::Region
StackId:
Value: !Ref AWS::StackId
Endpoint:
Value: !GetAtt [CFDistribution, DomainName]