This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathserverless.yml
118 lines (111 loc) · 3.17 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
service: serverless-url-shortener
plugins:
- serverless-webpack
- serverless-finch
- serverless-cloudfront-invalidate
- serverless-plugin-reducer
- serverless-domain-manager
- serverless-scriptable-plugin
package:
individually: true
provider:
name: aws
endpointType: edge
runtime: nodejs10.x
stage: ${opt:stage, 'staging'}
region: ${env:REGION}
profile: ${env:AWS_PROFILE}
memorySize: 128
timeout: 30
tracing:
apiGateway: true
lambda: true
environment:
API_URL: ${env:API_URL}
API_DOMAIN: ${env:API_DOMAIN}
SHORT_URL: ${env:SHORT_URL}
SHORT_DOMAIN: ${env:SHORT_DOMAIN}
REGION: ${env:REGION}
BUCKET: ${self:custom.bucketBaseName}-origin
iamRoleStatements:
- Effect: Allow
Action:
- s3:PutObject
Resource: 'arn:aws:s3:::${self:provider.environment.BUCKET}/*'
custom:
bucketBaseName: ${self:service}-${self:provider.stage}
scriptHooks:
before:deploy:deploy:
- sls create_domain -v -s ${self:provider.stage}
before:client:deploy:deploy:
- STAGE=${self:provider.stage} API_URL=${env:API_URL} yarn build
after:deploy:finalize:
- echo Y | sls client deploy -v -s ${self:provider.stage}
after:client:deploy:deploy:
- sls cloudfrontInvalidate -v -s ${self:provider.stage}
webpack:
webpackConfig: webpack.config.js
packager: yarn
includeModules: false
# excludeFiles:
cloudfrontInvalidate:
# Output key
distributionIdKey: ClientDistributionId
items:
- /
- /index.html
customDomain:
domainName: ${env:API_DOMAIN}
certificateName: ${env:API_CERTIFICATE_NAME}
hostedZoneId: ${env:API_HOSTED_ZONE}
createRoute53Record: true
endpointType: edge
basePath: ${env:API_BASE_ENDPOINT}
client:
manageResources: false
bucketName: ${self:provider.environment.BUCKET}
distributionFolder: ./build/
# objectHeaders:
# # Don't cache index so invalidation is not necessary
# # See: https://github.com/fernando-mc/serverless-finch/issues/40#issuecomment-406274331
# '*.html':
# - name: Cache-Control
# value: no-cache
# ALL_OBJECTS:
functions:
store:
handler: api/store.handle
events:
- http:
path: /store
method: post
cors: true
# See: https://github.com/sprockow/serverless-finch-example
resources:
- Parameters:
BucketName:
Type: String
Default: ${self:provider.environment.BUCKET}
LogBucketName:
Type: String
Default: ${self:custom.bucketBaseName}-logs
TargetOriginId:
Type: String
Default: ${self:custom.bucketBaseName}-target
DomainName:
Type: String
Default: ${env:SHORT_DOMAIN}
DomainNameHostedZoneId:
Type: String
Default: ${env:SHORT_HOSTED_ZONE}
CustomErrorResponsePagePath:
Type: String
Default: /index.html
ClientDistributionCertificate:
Type: String
Default: ${env:SHORT_DOMAIN_ACM_ARN}
- ${file(./resources/s3-bucket.yml)}
- ${file(./resources/s3-policies.yml)}
- ${file(./resources/dns-records.yml)}
- ${file(./resources/cf-distribution.yml)}
- ${file(./resources/outputs.yml)}