-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
233 lines (215 loc) · 6.63 KB
/
template.yaml
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
223
224
225
226
227
228
229
230
231
232
233
# This is the SAM template that represents the architecture of your serverless application
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-basics.html
# The AWSTemplateFormatVersion identifies the capabilities of the template
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/format-version-structure.html
AWSTemplateFormatVersion: 2010-09-09
Description: >-
sam-serverless-api
# Transform section specifies one or more macros that AWS CloudFormation uses to process your template
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html
Transform:
- AWS::Serverless-2016-10-31
Parameters:
DbConnUri:
Type: String
Description: Mongo DB Connection String
DbName:
Type: String
Description: Mongo DB database name
Default: "setu_db"
Globals:
Function:
Layers:
- !Ref FunctionLayer
- !Ref DependencyLayer
Runtime: nodejs18.x
Environment:
Variables:
DB_CONN_URI: !Ref DbConnUri
DB_NAME: !Ref DbName
# Resources declares the AWS resources that you want to include in the stack
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html
Resources:
RunoArogyamApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
Auth:
# AddDefaultAuthorizerToCorsPreflight: false
DefaultAuthorizer: RunoLambdaRequestAuthorizer
Authorizers:
RunoLambdaRequestAuthorizer:
FunctionPayloadType: REQUEST
FunctionArn: !GetAtt AuthorizeHandlerFunction.Arn
Identity:
Headers:
- Authorization
ReauthorizeEvery: 0
DependencyLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: dependency-layer
ContentUri: layers/dependencies/
CompatibleRuntimes:
- nodejs18.x
RetentionPolicy: Retain
FunctionLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: FunctionLayer
ContentUri: layers/functions
CompatibleRuntimes:
- nodejs18.x
RetentionPolicy: Retain
# Each Lambda function is defined by properties:
# https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
# This is a Lambda function config associated with the source code: get-all-items.js
AuthorizeHandlerFunction:
Type: AWS::Serverless::Function
Properties:
Description: API lambda authorizer.
Handler: src/auth/authorizer/app.authorizeHandler
Runtime: nodejs18.x
Timeout: 100
registerUserFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/auth/
Handler: register/app.registerUserHandler
Runtime: nodejs18.x
Architectures:
- x86_64
MemorySize: 128
Timeout: 100
Description: API to register a user.
Events:
RegisterUserEvent:
Type: Api
Properties:
RestApiId: !Ref RunoArogyamApi
Path: /api/v1/auth/register
Method: POST
Auth:
Authorizer: NONE
loginUserFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/auth/
Handler: login/app.loginUserHandler
Runtime: nodejs18.x
Architectures:
- x86_64
MemorySize: 128
Timeout: 100
Description: API to login a user.
Events:
LogUserEvent:
Type: Api
Properties:
RestApiId: !Ref RunoArogyamApi
Path: /api/v1/auth/login
Method: POST
Auth:
Authorizer: NONE
manageSlotFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/user/
Handler: manageSlot/app.manageSlotHandler
Runtime: nodejs18.x
Architectures:
- x86_64
MemorySize: 128
Timeout: 100
Description: API to create, update, delete a slot for particular user.
Events:
CancelSlotEvent:
Type: Api
Properties:
RestApiId: !Ref RunoArogyamApi
Path: /api/v1/user/manageSlot
Method: DELETE
UpsertSlotEvent:
Type: Api
Properties:
RestApiId: !Ref RunoArogyamApi
Path: /api/v1/user/manageSlot
Method: POST
getAllUserSlotsFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/user/
Handler: getAllSlots/app.getAllUserSlotsHandler
Runtime: nodejs18.x
Architectures:
- x86_64
MemorySize: 128
Timeout: 100
Description: API to create, update, delete a slot for particular user.
Events:
GetUserSlotsEvent:
Type: Api
Properties:
RestApiId: !Ref RunoArogyamApi
Path: /api/v1/user/getAllSlots
Method: GET
getAllSlotsDetailsFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/slots/
Handler: listAllSlots/app.listAllSlotsHandler
Runtime: nodejs18.x
Architectures:
- x86_64
MemorySize: 128
Timeout: 100
Description: API to list all available slots on a day.
Events:
GetAllSlotsByDateEvent:
Type: Api
Properties:
RestApiId: !Ref RunoArogyamApi
Path: /api/v1/slots/getAllSlots/{date}
Method: GET
Auth:
Authorizer: NONE
getAllSlotsForAdminFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/admin/
Handler: listSlots/app.adminDataHandler
Runtime: nodejs18.x
Architectures:
- x86_64
MemorySize: 128
Timeout: 100
Description: API to list all filterable admin priviliged data.
Events:
GetAllSlotsByDateEvent:
Type: Api
Properties:
RestApiId: !Ref RunoArogyamApi
Path: /api/v1/admin/listSlots/{date}
Method: GET
getAllUserListForAdminFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/admin/
Handler: listUsers/app.adminDataHandler
Runtime: nodejs18.x
Architectures:
- x86_64
MemorySize: 128
Timeout: 100
Description: API to list all filterable admin priviliged data.
Events:
GetAllUsersByFiltersEvent:
Type: Api
Properties:
RestApiId: !Ref RunoArogyamApi
Path: /api/v1/admin/listUsers
Method: GET
Outputs:
WebEndpoint:
Description: "API Gateway endpoint URL for Prod stage"
Value: !Sub "https://${RunoArogyamApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"