-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
144 lines (126 loc) · 3.37 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
service:
name: serverless-tg-bot-with-db-bootstrap
# app and org for use with dashboard.serverless.com
app: example
org: leovs09
plugins:
- serverless-webpack
- serverless-secrets-plugin
- serverless-mocha-plugin
# dynamodb-local must be loaded before offline for start automatically
- serverless-dynamodb-local
- serverless-offline
provider:
name: aws
stage: ${opt:stage, 'dev'}
runtime: nodejs12.x
apiGateway:
minimumCompressionSize: 1024 # Enable gzip compression for responses > 1 KB
environment:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
SECRET_SERVICE_KEY: ${self:custom.secrets.SECRET_SERVICE_KEY}
TELEGRAM_TOKEN: ${self:custom.secrets.TELEGRAM_TOKEN}
DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
custom:
secrets: ${file(./secrets.${opt:stage, self:provider.stage}.yml)}
webpack:
webpackConfig: ./webpack.config.js
includeModules:
forceExclude:
- aws-sdk
packager: 'yarn'
serverless-offline:
printOutput: true
noAuth: true
host: 0.0.0.0 # allow connect outside use only if you inside of container
dynamodb:
# If you only want to use DynamoDB Local in some stages, declare them here
stages:
- dev
start:
host: dynamo # or the name of your Dynamo docker container
port: "8000" # the port of our Dynamo docker container
noStart: true
# Will setup dynamodb on start with you Table scheme
migrate: true
# Define is need to inject data on start
#seed: true
#seed:
# source:
# test:
# sources:
# - table: TodosDynamoDbTable
# rawsources: [./fake-test-todo.json]
functions:
telegram:
handler: handler.telegram
events:
- http:
method: post
path: telegram
enviroment:
STAGE: ${self:provider.stage}
SECRET_FUNCTION_TOKEN: ${env:SECRET_FUNCTION_TOKEN}
create:
handler: todos/create.create
events:
- http:
path: todos
method: post
cors: true
list:
handler: todos/list.list
events:
- http:
path: todos
method: get
cors: true
get:
handler: todos/get.get
events:
- http:
path: todos/{id}
method: get
cors: true
update:
handler: todos/update.update
events:
- http:
path: todos/{id}
method: put
cors: true
delete:
handler: todos/delete.deleteFn
events:
- http:
path: todos/{id}
method: delete
cors: true
resources:
Resources:
TodosDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
TableName: ${self:provider.environment.DYNAMODB_TABLE}
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1