-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless.yml
175 lines (147 loc) · 4.35 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
170
171
172
173
174
175
service:
name: serverless-boilerplate
provider:
name: aws
runtime: nodejs6.10
cfLogs: true
stage: ${opt:stage, file(./config/output.yml):stage}
region: ${opt:region, file(./config/output.yml):region}
environment:
# MY_KMS_SECRET: ${self:custom.kmsSecrets.secrets.foo}
SERVERLESS_STAGE: ${opt:stage, self:provider.stage}
SERVERLESS_REGION: ${opt:region, self:provider.region}
SERVERLESS_PROJECT: ${self:service}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:*
Resource: arn:aws:dynamodb:*:*:table/${self:custom.my_table}
# # Enable the following IAM permissions for using KMS
# - Effect: Allow
# Action:
# - KMS:Decrypt
# Resource: ${self:custom.kmsSecrets.keyArn}
# Enable the following IAM permissions for using VPC Discovery
# - Effect: Allow
# Action:
# - ec2:CreateNetworkInterface
# - ec2:DescribeNetworkInterfaces
# - ec2:DeleteNetworkInterfaces
plugins:
# - serverless-vpc-discovery
# - serverless-domain-manager
- serverless-aws-documentation
- serverless-kms-secrets
- serverless-jest-plugin
- dynalite
- serverless-webpack
# - serverless-dynamodb-local
- serverless-offline
custom:
config: ${file(./config/output.yml)}
stage: ${opt:stage, self:custom.config.stage}
vpc_env: ${opt:vpc_env, self:custom.config.vpc_env}
prefix: ${self:custom.stage}-${self:service}
my_table: ${self:custom.config.db.tables.table}-${self:custom.stage}
# preTestCommands:
# - bash .tools/startOffline.sh
# postTestCommands:
# - bash .tools/stopOffline.sh
webpackIncludeModules: true
serverless-jest-plugin:
functionTemplate: config/templates/function-template.ejs
testTemplate: config/templates/test-template.ejs
# # For the serverless-kms-secrets plugin
# serverless-kms-secrets:
# secretsFile:
# secretsFile: kms2-secrets.${opt:stage, self:provider.stage}.${opt:region, self:provider.region}.yml # (optional)
# kmsSecrets: ${file(kms-secrets2.${opt:stage, self:provider.stage}.${opt:region, self:provider.region}.yml)}
# # For the serverless-domain-manager plugin
# customDomain:
# basePath: ${opt:stage, self:custom.stage}
# domainName: ${self:custom.config.domain.domainName}
# stage: ${opt:stage, self:custom.stage}
# # certificateName:
# # createRoute53Record: true
# For the serverless-vpc-discovery plugin
# vpc:
# vpcName: '${self:custom.stage}'
# subnetNames:
# - '${self:custom.stage}_NAME_OF_SUBNET'
# securityGroupNames:
# - '${self:custom.stage}_NAME_OF_SECURITY_GROUP'
dynamodb:
start:
port: 8000
inMemory: true
migrate: true
seed: true
# customDomain:
# basePath: ${self:custom.stage}
# domainName: boilerplate.foo.com
# stage: ${self:custom.stage}
# certificateName: # default: determined using domain name
# createRoute53Record: true # default: true
documentation:
api:
info:
${file(docs/info.yml)}
tags:
- name: MyTag
description: This is my tag
resources:
- path: '/health'
description: 'Endpoint to see if the serverless app is working'
- path: '/hello'
description: 'Joyful greeting by your Serverless Application'
models:
${file(docs/models.yml)}
functions:
health:
handler: handler.health
events:
- http:
method: get
path: health
cors: true
documentation:
${file(src/health.doc.yml)}
hello:
handler: handler.hello
events:
- http:
method: get
path: hello
cors: true
documentation:
${file(src/hello.doc.yml)}
error400:
handler: handler.error400
events:
- http:
method: get
path: error
cors: true
documentation:
${file(src/error400.doc.yml)}
# kms:
# handler: handler.kms
# events:
# - http:
# method: get
# path: kms
resources:
Resources:
serverlessBoilerplateTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.my_table}
AttributeDefinitions:
- AttributeName: email
AttributeType: S
KeySchema:
- AttributeName: email
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1