-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverless.yml
364 lines (343 loc) · 12 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
service: it-portfolio-manager-backend
frameworkVersion: '3'
useDotenv: true
provider:
name: aws
runtime: nodejs18.x
region: eu-south-1
timeout: 60
iam:
role:
statements:
- Effect: "Allow"
Action:
- "dynamodb:DescribeTable"
- "dynamodb:Query"
- "dynamodb:Scan"
- "dynamodb:GetItem"
- "dynamodb:PutItem"
- "dynamodb:UpdateItem"
- "dynamodb:DeleteItem"
- "dynamodb:BatchWriteItem"
Resource:
- "Fn::GetAtt": [ ItPortfolioManagerSkillMatrix, Arn ]
- "Fn::Join": [ '/', [ "Fn::GetAtt": [ ItPortfolioManagerSkillMatrix, Arn ], 'index', 'companyIndex' ] ]
- "Fn::GetAtt": [ ItPortfolioManagerUserProfile, Arn ]
- "Fn::Join": [ '/', [ "Fn::GetAtt": [ ItPortfolioManagerUserProfile, Arn ], 'index', 'companyIndex' ] ]
- "Fn::GetAtt": [ ItPortfolioManagerEffort, Arn ]
- "Fn::Join": [ '/', [ "Fn::GetAtt": [ ItPortfolioManagerEffort, Arn ], 'index', 'companyIndex' ] ]
- "Fn::GetAtt": [ ItPortfolioManagerTasks, Arn ]
- "Fn::GetAtt": [ ItPortfolioManagerTimeEntry, Arn ]
- "Fn::Join": [ '/', [ "Fn::GetAtt": [ ItPortfolioManagerTimeEntry, Arn ], 'index', 'companyIndex' ] ]
- "Fn::GetAtt": [ ItPortfolioManagerCrews, Arn ]
- "Fn::GetAtt": [ ItPortfolioManagerTaskProperties, Arn ]
- Effect: "Allow"
Action:
- "ssm:GetParameter"
Resource:
- arn:aws:ssm:${self:provider.region}:*:parameter/it-portfolio-manager/${opt:stage, 'dev'}/*
stackTags:
Owner: 'Massimo Biagioli'
Destroy: 'false'
plugins:
- serverless-plugin-typescript
- serverless-tscpaths
- serverless-dynamodb
- serverless-offline
custom:
vpc:
dev:
subnetIds:
- subnet-0dd2ae0510c3168cd
- subnet-003b9c2bd22cf8de4
securityGroupIds:
- sg-0f70cb05c44cdae65
test:
subnetIds:
- subnet-0dd2ae0510c3168cd
- subnet-003b9c2bd22cf8de4
securityGroupIds:
- sg-0f70cb05c44cdae65
stage:
subnetIds:
- subnet-0dd2ae0510c3168cd
- subnet-003b9c2bd22cf8de4
securityGroupIds:
- sg-0f70cb05c44cdae65
prod:
subnetIds:
- subnet-00e9390b3de78c81a
- subnet-00d78be45329823a6
securityGroupIds:
- sg-05b4669bc61b06099
variables:
stages:
- dev
- prod
- test
- stage
googleClientId:
dev: ${env:GOOGLE_CLIENT_ID, ''}
test: ${env:GOOGLE_CLIENT_ID, ''}
stage: /it-portfolio-manager/${opt:stage, 'dev'}/google-client-id
prod: /it-portfolio-manager/${opt:stage, 'dev'}/google-client-id
googleClientSecret:
dev: ${env:GOOGLE_CLIENT_SECRET, ''}
test: ${env:GOOGLE_CLIENT_SECRET, ''}
stage: /it-portfolio-manager/${opt:stage, 'dev'}/google-client-secret
prod: /it-portfolio-manager/${opt:stage, 'dev'}/google-client-secret
apiBaseUrl:
dev: http://localhost:3000
test: http://localhost:3000
stage: 'https://6w09n1v47j.execute-api.eu-south-1.amazonaws.com'
prod: 'https://8sl94yg50l.execute-api.eu-south-1.amazonaws.com'
serverless-dynamodb:
stages:
- dev
- test
start:
port: 8002
inMemory: true
heapInitial: 200m
heapMax: 1g
migrate: true
seed: true
convertEmptyValues: true
seed:
test:
sources:
- table: ItPortfolioManager-SkillMatrix-${opt:stage, 'dev'}
sources: [ ./seed/skill-matrix.json ]
- table: ItPortfolioManager-UserProfile-${opt:stage, 'dev'}
sources: [ ./seed/user-profile.json ]
- table: ItPortfolioManager-Effort-${opt:stage, 'dev'}
sources: [ ./seed/effort.json ]
- table: ItPortfolioManager-Task-${opt:stage, 'dev'}
rawsources: [ ./seed/task.json ]
- table: ItPortfolioManager-TaskProperties-${opt:stage, 'dev'}
rawsources: [ ./seed/task-properties.json ]
- table: "ItPortfolioManager-TimeEntry-${opt:stage, 'dev'}"
rawsources: [ ./seed/time-entry.json ]
- table: "ItPortfolioManager-Crew-${opt:stage, 'dev'}"
sources: ['./seed/crew.json']
package:
patterns:
- node_modules/**
- .serverless/**
- prisma/generated/**
- basic_model.conf
- basic_policy.csv
functions:
app:
handler: src/handlers/app.handler
vpc: ${self:custom.vpc.${opt:stage, 'dev'}}
environment:
STAGE_NAME: ${opt:stage, 'dev'}
OPENAI_API_KEY_ARN: /it-portfolio-manager/${opt:stage, 'dev'}/openai-api-key
BRICKLY_API_KEY_ARN: /it-portfolio-manager/${opt:stage, 'dev'}/brickly-api-key
GOOGLE_CLIENT_ID_ARN: ${self:custom.variables.googleClientId.${opt:stage, 'dev'}}
GOOGLE_CLIENT_SECRET_ARN: ${self:custom.variables.googleClientSecret.${opt:stage, 'dev'}}
GOOGLE_CALLBACK_URL: ${self:custom.variables.apiBaseUrl.${opt:stage, 'dev'}}/${opt:stage, 'dev'}/api/auth/google/oauthCallback
JWT_PRIVATE_KEY_ARN: /it-portfolio-manager/${opt:stage, 'dev'}/jwt-private-key
JWT_PUBLIC_KEY_ARN: /it-portfolio-manager/${opt:stage, 'dev'}/jwt-public-key
DATABASE_URL: ${ssm:/it-portfolio-manager/${opt:stage, 'dev'}/database-url}
FIND_TEAM_OPENAI_PROMPT: " Given the SKILL data:
[[SKILL]]
and EFFORT
[[EFFORT]]
mont_year refers to the month and year, expressed in the format MM_yy
if effort for one of the requested months is not present, consider avaiableEffort = 100%
avaiableEffort refers to the effort definitely available, possible avaiable effort refers to the effort potentially available
try to answer this question: [[QUESTION]]
Filter only the results that satisfy the effort condition
Sort the results first by skill score in descending order, then by effort in descending order
Provide the answer without generating code."
FIND_SKILLS_OPENAI_PROMPT: ' Your task is to extract the required skills from the sentence by selecting them from SKILLS, respond only with output_format
sentence: [[QUESTION]]
SKILLS:
[[SKILL_LIST]]
output_format: {"skills":[...]}" '
FIND_PERIOD_OPENAI_PROMPT: '
Your task is to find the time period described in the following sentence, respond only in the output_format format:
sentence: [[QUESTION]]
if year is not specified consider [[CURRENT_YEAR]]
output_format: {"start": mm_yy "month_number": ...}"'
events:
- http:
path: /
method: ANY
cors: true
- http:
path: /{any+}
method: ANY
cors: true
removeResignedPeople:
handler: src/handlers/removeResignedPeople.handler
vpc: ${self:custom.vpc.${opt:stage, 'dev'}}
events:
- schedule: cron(0 4 * * ? *)
environment:
STAGE_NAME: ${opt:stage, 'dev'}
SLACK_TOKEN_ARN: /it-portfolio-manager/${opt:stage, 'dev'}/slack-token
resources:
Resources:
ItPortfolioManagerSkillMatrix:
Type: AWS::DynamoDB::Table
Properties:
TableName: "ItPortfolioManager-SkillMatrix-${opt:stage, 'dev'}"
AttributeDefinitions:
- AttributeName: uid
AttributeType: S
- AttributeName: skill
AttributeType: S
- AttributeName: company
AttributeType: S
KeySchema:
- AttributeName: uid
KeyType: HASH
- AttributeName: skill
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
GlobalSecondaryIndexes:
- IndexName: companyIndex
KeySchema:
- AttributeName: company
KeyType: HASH
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
ItPortfolioManagerUserProfile:
Type: AWS::DynamoDB::Table
Properties:
TableName: "ItPortfolioManager-UserProfile-${opt:stage, 'dev'}"
AttributeDefinitions:
- AttributeName: uid
AttributeType: S
- AttributeName: company
AttributeType: S
KeySchema:
- AttributeName: uid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
GlobalSecondaryIndexes:
- IndexName: companyIndex
KeySchema:
- AttributeName: company
KeyType: HASH
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
ItPortfolioManagerEffort:
Type: AWS::DynamoDB::Table
Properties:
TableName: "ItPortfolioManager-Effort-${opt:stage, 'dev'}"
AttributeDefinitions:
- AttributeName: uid
AttributeType: S
- AttributeName: month_year
AttributeType: S
- AttributeName: company
AttributeType: S
KeySchema:
- AttributeName: uid
KeyType: HASH
- AttributeName: month_year
KeyType: RANGE
GlobalSecondaryIndexes:
- IndexName: companyIndex
KeySchema:
- AttributeName: company
KeyType: HASH
- AttributeName: month_year
KeyType: RANGE
Projection:
ProjectionType: ALL
BillingMode: PAY_PER_REQUEST
ItPortfolioManagerTasks:
Type: AWS::DynamoDB::Table
Properties:
TableName: "ItPortfolioManager-Task-${opt:stage, 'dev'}"
AttributeDefinitions:
- AttributeName: customerProject
AttributeType: S
- AttributeName: company
AttributeType: S
KeySchema:
- AttributeName: company
KeyType: HASH
- AttributeName: customerProject
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
ItPortfolioManagerTimeEntry:
Type: AWS::DynamoDB::Table
Properties:
TableName: "ItPortfolioManager-TimeEntry-${opt:stage, 'dev'}"
AttributeDefinitions:
- AttributeName: uid
AttributeType: S
- AttributeName: timeEntryDate
AttributeType: S
- AttributeName: company
AttributeType: S
KeySchema:
- AttributeName: uid
KeyType: HASH
- AttributeName: timeEntryDate
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
GlobalSecondaryIndexes:
- IndexName: companyIndex
KeySchema:
- AttributeName: company
KeyType: HASH
- AttributeName: timeEntryDate
KeyType: RANGE
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
ItPortfolioManagerCrews:
Type: AWS::DynamoDB::Table
Properties:
TableName: "ItPortfolioManager-Crew-${opt:stage, 'dev'}"
AttributeDefinitions:
- AttributeName: company
AttributeType: S
- AttributeName: name
AttributeType: S
KeySchema:
- AttributeName: company
KeyType: HASH
- AttributeName: name
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
ItPortfolioManagerTaskProperties:
Type: AWS::DynamoDB::Table
Properties:
TableName: "ItPortfolioManager-TaskProperties-${opt:stage, 'dev'}"
AttributeDefinitions:
- AttributeName: projectId
AttributeType: S
- AttributeName: task
AttributeType: S
KeySchema:
- AttributeName: projectId
KeyType: HASH
- AttributeName: task
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1