This repository has been archived by the owner on Mar 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
/
serverless.yml
169 lines (162 loc) · 4.49 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
service: nuxt-serverless
plugins:
- serverless-s3-sync
- serverless-apigw-binary
- serverless-dotenv-plugin
package:
individually: true
excludeDevDependencies: true
provider:
name: aws
runtime: nodejs10.x
stage: ${opt:stage, 'dev'}
region: us-east-1
custom:
#######################################
# Unique ID included in resource names.
# Replace it with a random value for every first distribution.
# https://www.random.org/strings/?num=1&len=6&digits=on&loweralpha=on&unique=on&format=html&rnd=new
stackId: lxpmd3
#######################################
buckets:
ASSETS_BUCKET_NAME: ${self:service}-${self:custom.stackId}-${self:provider.stage}-assets
STATIC_BUCKET_NAME: ${self:service}-${self:custom.stackId}-${self:provider.stage}-static
s3Sync:
- bucketName: ${self:custom.buckets.ASSETS_BUCKET_NAME}
localDir: .nuxt/dist/client
- bucketName: ${self:custom.buckets.STATIC_BUCKET_NAME}
localDir: static
apigwBinary:
types:
- '*/*'
functions:
renderer:
name: ${self:service}-${self:custom.stackId}-${self:provider.stage}-renderer
handler: .nuxt/dist/serverless.handler
memorySize: 2048
timeout: 30
environment:
NODE_ENV: production
package:
include:
- .nuxt/dist/serverless.js
- .nuxt/dist/server/**
exclude:
- .nuxt/**
- src/**
- app.js
- nuxt.config.js
- nuxt.d.ts
- README.md
- server.js
- serverless.js
- serverless.yml
- tsconfig.json
- tslint.json
- webpack.config.js
- yarn-error.log
events:
- http:
path: /
method: any
- http:
path: /{proxy+}
method: any
- http:
path: /_nuxt/{proxy+}
method: any
integration: http-proxy
request:
uri: https://${self:custom.buckets.ASSETS_BUCKET_NAME}.s3.${self:provider.region}.amazonaws.com/{proxy}
parameters:
paths:
proxy: true
- http:
path: /static/{proxy+}
method: any
integration: http-proxy
request:
uri: https://${self:custom.buckets.STATIC_BUCKET_NAME}.s3.${self:provider.region}.amazonaws.com/{proxy}
parameters:
paths:
proxy: true
resources:
Resources:
ClientAssetsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.buckets.ASSETS_BUCKET_NAME}
CorsConfiguration:
CorsRules:
-
AllowedOrigins:
- '*'
AllowedHeaders:
- '*'
AllowedMethods:
- GET
- HEAD
- PUT
- POST
- DELETE
MaxAge: 3000
ExposedHeaders:
- x-amz-server-side-encryption
- x-amz-request-id
- x-amz-id-2
ClientAssetsBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: ClientAssetsBucket
PolicyDocument:
Version: '2012-10-17'
Statement: [
{
Action: ['s3:GetObject'],
Effect: 'Allow',
Resource: {
Fn::Join: ['', ['arn:aws:s3:::', { Ref: 'ClientAssetsBucket' }, '/*']],
},
Principal: '*'
},
]
ClientStaticBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.buckets.STATIC_BUCKET_NAME}
CorsConfiguration:
CorsRules:
-
AllowedOrigins:
- '*'
AllowedHeaders:
- '*'
AllowedMethods:
- GET
- HEAD
- PUT
- POST
- DELETE
MaxAge: 3000
ExposedHeaders:
- x-amz-server-side-encryption
- x-amz-request-id
- x-amz-id-2
ClientStaticBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: ClientStaticBucket
PolicyDocument:
Version: '2012-10-17'
Statement: [
{
Action: ['s3:GetObject'],
Effect: 'Allow',
Resource: {
Fn::Join: ['', ['arn:aws:s3:::', { Ref: 'ClientStaticBucket' }, '/*']],
},
Principal: '*'
},
]