This repository was archived by the owner on May 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
110 lines (99 loc) · 3.22 KB
/
Copy pathserverless.yml
File metadata and controls
110 lines (99 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
service: react-elm-playground
provider:
name: aws
region: us-east-1
deploymentBucket: ${env:ARTIFACTS_BUCKET}
plugins:
- serverless-s3-sync
- serverless-cloudfront-invalidate
custom:
cloudfrontInvalidate:
distributionIdKey: DistributionIdKey
items:
- "/*"
s3Sync:
- acl: public-read
bucketName: ${env:DOMAIN_NAME}
localDir: dist
resources:
Mappings:
Constants:
CloudFront:
HostedZoneId: Z2FDTNDATAQYW2
Outputs:
DistributionIdKey:
Value:
Ref: Distribution
Resources:
Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${env:DOMAIN_NAME}
BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: {Ref: Bucket}
PolicyDocument:
Statement:
- Action: ['s3:GetObject']
Effect: Allow
Principal:
CanonicalUser: {Fn::GetAtt: CloudFrontOriginAccessIdentity.S3CanonicalUserId}
Resource:
- {Fn::Join: ['', ['arn:aws:s3:::', {Ref: Bucket}, '/*']]}
CloudFrontOriginAccessIdentity:
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: {Fn::Join: ['', ['access-identity-', {Ref: Bucket},'.s3.amazonaws.com']]}
Distribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Aliases:
- ${env:DOMAIN_NAME}
CustomErrorResponses:
- ErrorCachingMinTTL: 300
ErrorCode: 403
ResponseCode: 200
ResponsePagePath: /index.html
- ErrorCachingMinTTL: 300
ErrorCode: 404
ResponseCode: 200
ResponsePagePath: /index.html
DefaultCacheBehavior:
AllowedMethods: [GET, HEAD]
Compress: true
DefaultTTL: 30
ForwardedValues: {QueryString: true}
MinTTL: 10
TargetOriginId: S3Origin
ViewerProtocolPolicy: redirect-to-https
DefaultRootObject: index.html
Enabled: true
HttpVersion: http2
Origins:
- DomainName: {Fn::Join: ['', [{Ref: Bucket}, '.s3.amazonaws.com']]}
Id: S3Origin
S3OriginConfig:
OriginAccessIdentity: {Fn::Join: ['', ['origin-access-identity/cloudfront/', {Ref: CloudFrontOriginAccessIdentity}]]}
PriceClass: PriceClass_100
ViewerCertificate:
AcmCertificateArn: ${env:CERTIFICATE_ARN}
MinimumProtocolVersion: TLSv1.2_2019
SslSupportMethod: sni-only
RecordSetGroup:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneName: ${env:HOSTED_ZONE}.
RecordSets:
- Name: ${env:DOMAIN_NAME}.
Type: A
AliasTarget:
DNSName: {Fn::GetAtt: Distribution.DomainName}
HostedZoneId: {Fn::FindInMap: [Constants, CloudFront, HostedZoneId]}
- Name: ${env:DOMAIN_NAME}.
Type: AAAA
AliasTarget:
DNSName: {Fn::GetAtt: Distribution.DomainName}
HostedZoneId: {Fn::FindInMap: [Constants, CloudFront, HostedZoneId]}