This repository has been archived by the owner on May 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
124 lines (118 loc) · 3.77 KB
/
serverless.yml
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
service: polls
frameworkVersion: ">= 1.23.0 < 2.0.0"
provider:
name: aws
runtime: nodejs8.10
region: ap-northeast-2
environment:
NODE_ENV: production
plugins:
- serverless-s3-sync
custom:
domainName: cmygray.kr
fullDomainName: ${self:service}.${self:custom.domainName}
bucketName: ${self:custom.fullDomainName}
s3Sync:
- bucketName: ${self:custom.bucketName}
localDir: dist
resources:
Resources:
PollsAppCloudFrontOriginAccessIdentity:
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: ${self:service}
PollsAppBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.bucketName}
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: index.html
PollsAppBucketPolicy:
Type: AWS::S3::BucketPolicy
DependsOn:
- PollsAppCloudFrontOriginAccessIdentity
Properties:
Bucket:
Ref: PollsAppBucket
PolicyDocument:
Statement:
- Sid: CanonicalUserReadGetObject
Effect: Allow
Principal:
CanonicalUser:
Fn::GetAtt: [ PollsAppCloudFrontOriginAccessIdentity, S3CanonicalUserId ]
Action:
- s3:GetObject
Resource:
Fn::Join:
- ''
- - 'arn:aws:s3:::'
- Ref: PollsAppBucket
- '/*'
PollsAppCloudFrontDistribution:
Type: AWS::CloudFront::Distribution
DependsOn:
- PollsAppBucketPolicy
Properties:
DistributionConfig:
Aliases:
- ${self:custom.fullDomainName}
CustomErrorResponses:
- ErrorCode: 404
ResponseCode: 200
ResponsePagePath: /index.html
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
Compress: true
TargetOriginId: ${self:service}
ForwardedValues:
QueryString: false
Cookies:
Forward: none
ViewerProtocolPolicy: redirect-to-https
DefaultRootObject: index.html
Enabled: true
HttpVersion: http2
Logging:
IncludeCookies: 'false'
Bucket: ${self:custom.bucketName}.s3.amazonaws.com
Prefix: cf-logs
Origins:
- DomainName: ${self:custom.bucketName}.s3.amazonaws.com
Id: ${self:service}
S3OriginConfig:
OriginAccessIdentity:
Fn::Join:
- ''
- - 'origin-access-identity/cloudfront/'
- Ref: PollsAppCloudFrontOriginAccessIdentity
ViewerCertificate:
AcmCertificateArn: arn:aws:acm:us-east-1:326065082801:certificate/468a1825-1a58-46e1-9048-a266a82750dc
SslSupportMethod: sni-only
PollsAppDnsRecord:
Type: AWS::Route53::RecordSetGroup
DependsOn:
- PollsAppCloudFrontDistribution
Properties:
HostedZoneName: '${self:custom.domainName}.'
RecordSets:
- Name: ${self:custom.fullDomainName}
Type: A
AliasTarget:
HostedZoneId: Z2FDTNDATAQYW2 # https://docs.aws.amazon.com/ko_kr/general/latest/gr/rande.html#cf_region
DNSName:
Fn::GetAtt: [ PollsAppCloudFrontDistribution, DomainName ]
Outputs:
PollsAppBucket:
Value:
Ref: PollsAppBucket
PollsAppCloudFrontDistributionDomainName:
Value:
Fn::GetAtt: [ PollsAppCloudFrontDistribution, DomainName ]
FullDomain:
Value: ${self:custom.fullDomainName}