-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless.yml
169 lines (151 loc) · 4.93 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
#$file(service.yml)
service: 'backend'
# app and org for use with dashboard.serverless.com
app: 'appName'
org: 'orgName'
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
frameworkVersion: '3'
provider:
name: aws
runtime: nodejs14.x
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-1'}
httpApi:
cors: true
deploymentPrefix: meraid
deploymentBucket:
name: serverless-${self:custom.name}
blockPublicAccess: true
# skipPolicySetup: false
# memorySize: 512
versionFunctions: false
# Serverless defaults to "endpointType: edge". Use below to make it regional.
# endpointType: regional
# you can add statements to the Lambda function's IAM Role here
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/${self:custom.dynamodb.MainTable}
- arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/${self:custom.dynamodb.MainTable}/index/${self:custom.dynamodb.MainTableGSI1}
# - arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/${self:custom.dynamodb.MainTable}/index/${self:custom.dynamodb.MainTableGSI2}
environment:
IS_OFFLINE: ${opt:IS_OFFLINE, false}
REGION: ${self:provider.region}
STAGE: ${self:provider.stage}
DYNAMODB_MAIN_TABLE: ${self:custom.dynamodb.MainTable}
package:
patterns:
- '!.dynamodb/**'
- '!./templates/**'
- '!./.temp/**'
- '!./__test__/**'
- '!./.vscode/**'
- '!./**/*.spec.js'
functions:
helloWorld:
handler: src/controllers/index.helloWorldC
middleware:
pre:
- src/middleware/index.jwtAuth
events:
- httpApi:
method: any
path: /v1/hello-world
iamRoleStatementsInherit: true
iamRoleStatements:
- Effect: Allow
Action:
- s3:GetObject
Resource: 'arn:aws:s3:::${self:custom.s3.MediaBucket}/*'
# '*' # TODO: later we should replace it with working ARN instead of a wildcard
- Effect: Allow # sendEmail permission
Action:
- 'ses:SendEmail'
- 'ses:SendRawEmail'
Resource: '*'
plugins:
- serverless-dynamodb-local
- serverless-offline
- serverless-pseudo-parameters
- '@serverless/safeguards-plugin'
- serverless-export-env
- serverless-middleware
- serverless-domain-manager
- serverless-iam-roles-per-function
- serverless-plugin-scripts
- serverless-deployment-bucket
# for individual dev provide your initials in CLI arguments when deploying e.g. --STAGE=UJ * stage name shall be smaller alphabets
# Do not change serverless.yml, and please do not commit.
params:
default:
backendDomain: api-${sls:stage}.dev.${self:custom.domain}
frontendDomain: https://${sls:stage}.dev.${self:custom.domain}
certificateName: dev.${self:custom.domain}
region: 'us-east-1'
s3BucketName: ${self:custom.domain}-${sls:stage}-${param:region}-media
sourceEmail: no-reply@${param:certificateName}
dev:
backendDomain: api.dev.${self:custom.domain}
frontendDomain: https://dev.${self:custom.domain}
certificateName: dev.${self:custom.domain}
region: 'us-east-1'
s3BucketName: ${self:custom.domain}-dev-${param:region}-media
sourceEmail: no-reply@${param:certificateName}
# prod:
# backendDomain: api.${self:custom.domain}
# frontendDomain: https://${self:custom.domain}
# certificateName: ${self:custom.domain}
# region: 'eu-central-1'
# s3BucketName: ${self:custom.domain}-${param:region}-media
# sourceEmail: no-reply@${param:certificateName}
# staging:
# frontendDomain: https://preview.${self:custom.domain}
# backendDomain: api.preview.${self:custom.domain}
# certificateName: preview.${self:custom.domain}
# region: 'eu-central-1'
# s3BucketName: ${self:custom.domain}-preview-${param:region}-media
# sourceEmail: no-reply@${param:certificateName}
custom:
# domain: myapp.pk
# name: ${self:app}-${self:service}-${sls:stage}
# customDomain:
# domainName: ${param:backendDomain}
# stage: ${sls:stage}
# certificateName: ${param:certificateName}
# createRoute53Record: true
# createRoute53IPv6Record: true
# endpointType: 'regional'
# apiType: http
# autoDomain: true
dynamodb:
MainTable: ${self:service}-${self:provider.stage}
MainTableGSI1: GSI1
stages:
- dev
- pre-prod
- prod
start:
dbPath: ./.dynamodb/data/
migrate: true
s3:
MediaBucket: ${param:s3BucketName}
middleware:
folderName: src/.middleware
cleanFolder: true
scripts:
hooks:
'before:deploy:deploy': npm run lint
export-env:
filename: .env
overwrite: true