-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
139 lines (126 loc) · 3.46 KB
/
serverless.yml
File metadata and controls
139 lines (126 loc) · 3.46 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
service: ssr-test
provider:
name: aws
runtime: nodejs12.x
region: ${opt:region, 'us-east-1'}
stage: ${opt:stage, 'dev'}
memorySize: 512
timeout: 6
logRetentionInDays: 7
environment:
API_URL: https://api.dev.external.hollywood.com
API_KEY: kiC7PB8QCRio6XqFJmj3PiH6sbAsBhxYre6bSH9t
GZIP_ENABLED: false
STRIPE_PK: pk_test_TYooMQauvdEDq54NiTphI7jx
SERVERLESS_PROJECT: ${self:service}
SERVERLESS_REGION: ${self:provider.region}
SERVERLESS_STAGE: ${self:provider.stage}
APP_DIST_URL: ${self:custom.distBucketUrl.${self:provider.region}, self:custom.distBucketUrl.default}
APP_PUBLIC_URL: ${self:custom.distBucketUrl.${self:provider.region}, self:custom.distBucketUrl.default}
APIGATEWAY_URL:
Fn::Join:
- ""
- - https://
- Ref: ApiGatewayRestApi
- .execute-api.
- Ref: AWS::Region
- .amazonaws.com/
- ${self:provider.stage}
plugins:
- serverless-webpack
- serverless-export-env
- serverless-plugin-scripts
- serverless-offline
- serverless-s3-deploy
functions:
serve:
# Any web request regardless of path or method will be handled by a single Lambda function
handler: handler.serve
events:
- http:
path: /
method: any
cors: true
- http:
path: /{any+}
method: any
cors: true
custom:
distBucketUrl:
us-east-1:
# us-east-1 uses a different URL format than the other regions
Fn::Join:
- ""
- - https://s3.amazonaws.com/
- Ref: DistBucket
default:
# All other regions
Fn::Join:
- ""
- - https://s3-
- Ref: AWS::Region
- .amazonaws.com/
- Ref: DistBucket
scripts:
hooks:
# Build the client-side script before packaging backend code
package:initialize: "npm run build:browser"
deploy:finalize: "npx sls s3deploy"
webpack:
webpackConfig: "webpack.server.config.js"
assets:
# Automatically copying public folder and distribution to S3 stopped working; we do it manually now
auto: false
targets:
- bucket:
Ref: DistBucket
acl: public-read
files:
- source: public/
globs:
- "**/*"
- source: dist/
headers:
CacheControl: max-age=31104000 # 1 year
globs:
- "**/*.js"
- "**/*.css"
- "**/*.map"
resources:
Resources:
# Customize the API Gateway resource
ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
# Enable gzip compression
MinimumCompressionSize: 1000
# S3 Bucket for the distribution bundles
DistBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Delete
Properties:
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- "*"
AllowedMethods:
- "GET"
AllowedOrigins:
- Fn::Join:
- ""
- - https://
- Ref: ApiGatewayRestApi
- .execute-api.
- Ref: AWS::Region
- .amazonaws.com
MaxAge: 3000
Outputs:
ApiGatewayRestApi:
Description: API Gateway Endpoint
Value:
Ref: ApiGatewayRestApi
DistBucket:
Description: Distribution S3 Bucket
Value:
Ref: DistBucket