-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
222 lines (209 loc) · 6.34 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
org: ddakib
app: telegram-bot-handler
service: carpooling-telegram-bot
custom:
pythonRequirements:
dockerizePip: non-linux
provider:
name: aws
runtime: python3.9
architecture: arm64
stage: dev
region: eu-central-1
timeout: 20
iamRoleStatements:
- Effect: Allow
Action: 'dynamodb:*'
Resource: '*'
environment:
TELEGRAM_TOKEN: ${env:BOT_TOKEN}
ALCHEMY_API_URL: ${env:ALCHEMY_API_URL}
WALLET_PRIVATE_KEY: ${env:WALLET_PRIVATE_KEY}
ONBOARDING_CONTRACT_ADDRESS: ${env:ONBOARDING_SERVICE_ADDRESS}
PAYMENT_CONTRACT_ADDRESS: ${env:PAYMENT_PROCESSING_SERVICE_ADDRESS}
WALLET_ADDRESS: ${env:WALLET_ADDRESS}
VEHICLE_MANAGEMENT_SERVICE_ADDRESS: ${env:VEHICLE_MANAGEMENT_SERVICE_ADDRESS}
ROUTING_SERVICE_API_KEY: AIzaSyDQEqeNOjLEhMSpiIp1-EnUgyJFdRGA4cI
package:
patterns:
- '!.venv'
- '!.gitignore'
functions:
handle_user_message:
handler: src.message_handler.handler
events:
- http:
path: /bot/message
method: post
cors: true
handle_transaction_event_emitted:
handler: src.ts_event_handler.handler
events:
- http:
path: /smart-contract/event
method: post
cors: true
handle_scheduled_notification:
handler: src.notification_schedule_handler.handler
events:
- schedule:
rate: rate(5 minutes)
enabled: true
plugins:
- serverless-python-requirements
resources:
Resources:
EthereumTransactionsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ethereum-transactions-table
AttributeDefinitions:
- AttributeName: pk # tx_hash
AttributeType: S
- AttributeName: gsi1_pk # chat_id
AttributeType: N
KeySchema:
- AttributeName: pk
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: gsi1
KeySchema:
- AttributeName: gsi1_pk
KeyType: HASH
Projection:
ProjectionType: 'ALL'
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
BillingMode: PAY_PER_REQUEST
ChatStateTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: user-chat-state-table
AttributeDefinitions:
- AttributeName: pk # chat_id
AttributeType: N
- AttributeName: username
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: gsi1
KeySchema:
- AttributeName: username
KeyType: HASH
Projection:
ProjectionType: 'ALL'
BillingMode: PAY_PER_REQUEST
UserInfoTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: user-info-table
AttributeDefinitions:
- AttributeName: pk # username
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
BillingMode: PAY_PER_REQUEST
RoutesTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: routes-table-v2
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
- AttributeName: sk
AttributeType: S
- AttributeName: owner_username
AttributeType: S
- AttributeName: route_id
AttributeType: S
- AttributeName: chat_id
AttributeType: N
- AttributeName: route_name
AttributeType: S
- AttributeName: source_geohash_close
AttributeType: S
- AttributeName: destination_geohash_close
AttributeType: S
- AttributeName: source_geohash_mid
AttributeType: S
- AttributeName: destination_geohash_mid
AttributeType: S
- AttributeName: source_geohash_long
AttributeType: S
- AttributeName: destination_geohash_long
AttributeType: S
- AttributeName: gsi3pk
AttributeType: S
- AttributeName: gsi3sk
AttributeType: S
- AttributeName: gsi4pk
AttributeType: S
- AttributeName: start_time_epoch
AttributeType: N
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: sk
KeyType: RANGE
GlobalSecondaryIndexes:
- IndexName: gsi1
KeySchema:
- AttributeName: chat_id
KeyType: HASH
- AttributeName: route_id
KeyType: RANGE
Projection:
ProjectionType: 'ALL'
- IndexName: gsi2
KeySchema:
- AttributeName: route_name
KeyType: HASH
- AttributeName: owner_username
KeyType: RANGE
Projection:
ProjectionType: 'ALL'
- IndexName: gsi3
KeySchema:
- AttributeName: gsi3pk
KeyType: HASH
- AttributeName: gsi3sk
KeyType: RANGE
Projection:
ProjectionType: 'ALL'
- IndexName: close_range_routes_geohash
KeySchema:
- AttributeName: source_geohash_close
KeyType: HASH
- AttributeName: destination_geohash_close
KeyType: RANGE
Projection:
ProjectionType: 'ALL'
- IndexName: mid_range_routes_geohash
KeySchema:
- AttributeName: source_geohash_mid
KeyType: HASH
- AttributeName: destination_geohash_mid
KeyType: RANGE
Projection:
ProjectionType: 'ALL'
- IndexName: long_range_routes_geohash
KeySchema:
- AttributeName: source_geohash_long
KeyType: HASH
- AttributeName: destination_geohash_long
KeyType: RANGE
Projection:
ProjectionType: 'ALL'
- IndexName: gsi4
KeySchema:
- AttributeName: gsi4pk
KeyType: HASH
- AttributeName: start_time_epoch
KeyType: RANGE
Projection:
ProjectionType: 'ALL'
BillingMode: PAY_PER_REQUEST