-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless-x.yml
174 lines (163 loc) · 4.46 KB
/
serverless-x.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
170
171
172
173
174
service: aws-vite-ssr-vuetify
frameworkVersion: '2'
plugins:
- serverless-domain-manager
- serverless-s3-sync
- serverless-api-gateway-caching
provider:
name: aws
runtime: nodejs14.x
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-1'}
versionFunctions: false
lambdaHashingVersion: 20201221
apiGateway:
shouldStartNameWithService: true
environment: ${file(env.yml):${self:provider.stage}}
package:
exclude:
- static/**
custom:
env: ${self:provider.environment}
customDomain:
domainName: ${self:custom.env.APP_DOMAIN}
certificateName: ${self:custom.env.APP_CERTIFICATE_NAME}
createRoute53Record: true
endpointType: 'regional'
securityPolicy: tls_1_2
apiType: rest
autoDomain: true
enabled: true
buckets:
staticFilesBucketName: ${self:provider.stage}-${self:service}-static
s3Sync:
- bucketName: ${self:custom.buckets.staticFilesBucketName}
localDir: static
deleteRemoved: false
functions:
ssr:
handler: server/ssr.handler
reservedConcurrency: 4
timeout: 30
role: SsrRoleV1
events:
- http:
path: /
method: any
caching:
enabled: false
- http:
path: /{proxy+}
method: any
caching:
enabled: false
api:
handler: api/index.api
reservedConcurrency: 4
timeout: 30
role: ApiRoleV1
events:
- http:
path: /api/v1/{any+}
method: ANY
cors: true
caching:
enabled: false
resources:
Resources:
SsrRoleV1:
Type: AWS::IAM::Role
Properties:
RoleName: ${self:service}-${self:provider.stage}-SsrRoleV1
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
- Effect: Allow
Principal:
Service:
- edgelambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: ${self:service}-${self:provider.stage}-SsrPolicyV1
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: "Allow"
Action:
- logs:*
Resource: "*"
ApiRoleV1:
Type: AWS::IAM::Role
Properties:
RoleName: ${self:service}-${self:provider.stage}-ApiRoleV1
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
- Effect: Allow
Principal:
Service:
- edgelambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: ${self:service}-${self:provider.stage}-ApiPolicyV1
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: "Allow"
Action:
- logs:*
Resource: "*"
- Effect: "Allow"
Action:
- s3:ListBucket
- s3:GetObject
Resource: "arn:aws:s3:::${self:custom.buckets.staticFilesBucketName}/*"
SiteStaticBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.buckets.staticFilesBucketName}
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
SiteStaticBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: SiteStaticBucket
PolicyDocument:
Version: '2012-10-17'
Statement: [
{
Action: ['s3:GetObject'],
Effect: 'Allow',
Resource: {
Fn::Join: ['', ['arn:aws:s3:::', { Ref: 'SiteStaticBucket' }, '/*']],
},
Principal: '*'
},
]