This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
168 lines (161 loc) · 4.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
service: easy-tfa-server-aws
frameworkVersion: '3'
provider:
name: aws
runtime: nodejs14.x
httpApi:
cors: true
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:DeleteItem
- dynamodb:BatchWriteItem
Resource:
Fn::GetAtt:
- dynamoDbTable
- Arn
- Effect: Allow
Action:
- dynamodb:Query
Resource:
Fn::Join:
- /
- - Fn::GetAtt:
- dynamoDbTable
- Arn
- index
- NotificationEndpointIndex
websocketsApiRouteSelectionExpression: $request.body.event
environment:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
DYNAMODB_TABLE_NAME:
Ref: dynamoDbTable
WS_ENDPOINT:
Fn::Join:
-
- - https://
- Ref: WebsocketsApi
- .execute-api.
- Ref: AWS::Region
- .
- Ref: AWS::URLSuffix
- /
- ${opt:stage, 'dev'}
region: ${opt:region, 'eu-central-1'}
stage: ${opt:stage, 'dev'}
logRetentionInDays: 14
versionFunctions: false
architecture: arm64
plugins:
- serverless-webpack
functions:
healthcheck:
handler: src/handler/healthcheck.handler
memorySize: 128
events:
- httpApi:
method: GET
path: /healthcheck
config:
handler: src/handler/config.handler
memorySize: 128
events:
- httpApi:
method: GET
path: /config
environment:
NOTIFICATION_API_KEY: ${ssm:/easytfa/${opt:stage, 'dev'}/push-notifications/api-key, ''}
NOTIFICATION_APPLICATION_ID: ${ssm:/easytfa/${opt:stage, 'dev'}/push-notifications/application-id, ''}
NOTIFICATION_PROJECT_ID: ${ssm:/easytfa/${opt:stage, 'dev'}/push-notifications/project-id, ''}
publicKey:
handler: src/handler/publicKey.handler
memorySize: 512
events:
- httpApi:
method: POST
path: /public-key-by-hash
codeQueries:
handler: src/handler/codeQueries.handler
memorySize: 512
events:
- httpApi:
method: POST
path: /code-queries-by-hashes
message:
handler: src/handler/message.handler
memorySize: 512
events:
- httpApi:
method: POST
path: /message
registerNotificationEndpoint:
handler: src/handler/registerNotificationEndpoint.handler
memorySize: 512
events:
- httpApi:
method: POST
path: /register-notification-endpoint
websocketLinking:
handler: src/handler/websocketLinking.handler
memorySize: 512
events:
- websocket:
route: 'start-linking'
routeResponseSelectionExpression: $default
websocketQuery:
handler: src/handler/websocketQuery.handler
memorySize: 512
events:
- websocket:
route: 'query-code'
routeResponseSelectionExpression: $default
environment:
NOTIFICATION_PROJECT_ID: ${ssm:/easytfa/${opt:stage, 'dev'}/push-notifications/project-id, ''}
NOTIFICATION_FIREBASE_ADMINSDK: ${ssm(raw):/easytfa/${opt:stage, 'dev'}/push-notifications/firebase-adminsdk, ''}
resources:
Resources:
dynamoDbTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: primaryKey
AttributeType: S
- AttributeName: notificationEndpoint
AttributeType: S
KeySchema:
- AttributeName: primaryKey
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TimeToLiveSpecification:
AttributeName: expirationTime
Enabled: true
GlobalSecondaryIndexes:
- IndexName: NotificationEndpointIndex
KeySchema:
- AttributeName: notificationEndpoint
KeyType: HASH
Projection:
ProjectionType: KEYS_ONLY
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
custom:
dynamodb:
stages:
- dev
webpack:
webpackConfig: './webpack.config.js'
includeModules:
forceExclude:
- aws-sdk
- fast-crc32c
- request
package:
individually: true