-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.ts
196 lines (193 loc) · 6.96 KB
/
serverless.ts
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
import type { AWS } from '@serverless/typescript';
import firstResponder from '@functions/firstResponder';
import createFunction from '@functions/createFunction';
import scheduler from '@functions/scheduler';
import runner from '@functions/runner';
import returner from '@functions/returner';
import awsRunner from '@functions/aws/awsRunner';
import awsReturner from '@functions/aws/awsReturner';
import optimizationRequest from '@functions/logging/optimizationRequest';
import runRequest from '@functions/logging/runRequest';
import status from '@functions/status';
import functionService from '@functions/user/function';
import loginService from '@functions/user/login';
import signInService from '@functions/user/signIn';
import logWatcher from '@functions/logWatcher';
import authorizer from '@functions/authorizer';
import deleteUser from '@functions/user/delete';
const serverlessConfiguration: AWS = {
service: 'foppa',
configValidationMode: 'error',
frameworkVersion: '3',
plugins: ['serverless-esbuild'],
provider: {
name: 'aws',
profile: 'foppa',
region: 'eu-central-1',
runtime: 'nodejs18.x',
stage: 'dev',
stackTags: {
Project: 'Foppa',
Deployment: 'Serverless',
Author: 'Hendrik',
},
apiGateway: {
minimumCompressionSize: 1024,
shouldStartNameWithService: true,
},
httpApi: {
authorizers: {
authorizer: {
type: 'request',
functionName: 'authorizer',
identitySource: ['$request.header.Authorization'],
resultTtlInSeconds: 300,
enableSimpleResponse: true,
}
}
},
environment: {
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
NODE_OPTIONS: '--enable-source-maps --stack-trace-limit=1000',
},
iam: {
role: 'arn:aws:iam::717556240325:role/Foppa_full_lambda_role',
},
deploymentBucket: {
name: '${self:service}-deployment-${self:provider.stage}',
},
},
// import the function via paths
functions: {
firstResponder,
createFunction,
scheduler,
runner,
awsRunner,
awsReturner,
optimizationRequest,
runRequest,
returner,
status,
functionService,
loginService,
signInService,
logWatcher,
authorizer,
deleteUser
},
package: { individually: true },
custom: {
esbuild: {
bundle: true,
minify: false,
sourcemap: true,
exclude: ['aws-sdk'],
target: 'node18',
define: { 'require.resolve': undefined },
platform: 'node',
concurrency: 10,
},
},
resources: {
Resources: {
LogBucket: {
Type: 'AWS::S3::Bucket',
Properties: {
BucketName: 'foppa-logs',
},
},
DeploymentBucket: {
Type: 'AWS::S3::Bucket',
Properties: {
BucketName: 'foppa',
},
},
// OptimizationRequestTopic: {
// Type: 'AWS::SNS::Topic',
// Properties: {
// DisplayName: 'Optimization Request Topic',
// TopicName: 'OptimizationRequestTopic',
// },
// },
// RunRequestTopic: {
// Type: 'AWS::SNS::Topic',
// Properties: {
// DisplayName: 'Run Request Topic',
// TopicName: 'RunRequestTopic',
// },
// },
FunctionExecutionCounter: {
Type: 'AWS::DynamoDB::Table',
Properties: {
TableName: 'FunctionExecutionCounter',
AttributeDefinitions: [
{ AttributeName: 'username', AttributeType: 'S' },
{ AttributeName: 'functionId', AttributeType: 'S' },
// { AttributeName: 'executionCounter', AttributeType: 'N' },
],
KeySchema: [
{ AttributeName: 'username', KeyType: 'HASH' },
{ AttributeName: 'functionId', KeyType: 'RANGE' },
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
},
},
},
RegionExecutionCounter: {
Type: 'AWS::DynamoDB::Table',
Properties: {
TableName: 'RegionExecutionCounter',
AttributeDefinitions: [
{ AttributeName: 'uFunctionId', AttributeType: 'S' },
{ AttributeName: 'pregion', AttributeType: 'S' },
// { AttributeName: 'executionCounter', AttributeType: 'N' },
],
KeySchema: [
{ AttributeName: 'uFunctionId', KeyType: 'HASH' },
{ AttributeName: 'pregion', KeyType: 'RANGE' },
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
},
},
},
RegionRunnerURL: {
Type: 'AWS::DynamoDB::Table',
Properties: {
TableName: 'RegionRunnerURL',
AttributeDefinitions: [
{ AttributeName: 'uFunctionId', AttributeType: 'S' },
{ AttributeName: 'pregion', AttributeType: 'S' },
// { AttributeName: 'functionName', AttributeType: 'S' },
// { AttributeName: 'url', AttributeType: 'S' },
],
KeySchema: [
{ AttributeName: 'uFunctionId', KeyType: 'HASH' },
{ AttributeName: 'pregion', KeyType: 'RANGE' },
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
},
},
},
UserManager: {
Type: 'AWS::DynamoDB::Table',
Properties: {
TableName: 'UserManager',
AttributeDefinitions: [{ AttributeName: 'username', AttributeType: 'S' }],
KeySchema: [{ AttributeName: 'username', KeyType: 'HASH' }],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
},
},
},
},
},
};
module.exports = serverlessConfiguration;