-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.ts
More file actions
93 lines (87 loc) · 2.78 KB
/
serverless.ts
File metadata and controls
93 lines (87 loc) · 2.78 KB
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
import type { AWS } from '@serverless/typescript';
import * as functions from '@functions/index';
import custom from './serverless/custom';
const patterns = [
'!node_modules/prisma',
'!node_modules/@prisma/engines',
'!node_modules/.prisma/**/libquery_engine-*',
];
const environment: Record<string, string> = {
NODE_OPTIONS: '--enable-source-maps --stack-trace-limit=1000',
POWERTOOLS_SERVICE_NAME: '${file(./package.json):name}',
POWERTOOLS_LOG_LEVEL: 'INFO',
DATABASE_HOST: '${ssm:/rds-host}',
DATABASE_USER: '${ssm:/rds-user}',
DATABASE_PASSWORD: '${ssm:/rds-password}',
DATABASE_URL:
'postgresql://${self:provider.environment.DATABASE_USER}:${self:provider.environment.DATABASE_PASSWORD}@${self:provider.environment.DATABASE_HOST}/borrowlend:main?sslmode=require',
SHADOW_DATABASE_URL:
'postgresql://${self:provider.environment.DATABASE_USER}:${self:provider.environment.DATABASE_PASSWORD}@${self:provider.environment.DATABASE_HOST}/shadow:main?sslmode=require',
};
if (process.env.IS_LOCAL === 'true') {
patterns.push('node_modules/.prisma/client/libquery_engine-darwin-*');
}
if (process.env.IS_DEPLOYING === 'true') {
environment['PRISMA_QUERY_ENGINE_LIBRARY'] = '/opt/nodejs/prisma/libquery_engine-linux-arm64-openssl-3.0.x.so.node';
}
const serverlessConfiguration: AWS = {
service: '${file(./package.json):name}',
frameworkVersion: '3',
plugins: [
'serverless-esbuild',
'serverless-offline',
'serverless-export-env',
'serverless-plugin-warmup',
'serverless-offline-local-authorizers-plugin',
'serverless-iam-roles-per-function',
'serverless-domain-manager',
],
provider: {
name: 'aws',
runtime: 'nodejs20.x',
architecture: 'arm64',
versionFunctions: false,
stage: '${opt:stage, self:custom.defaultStage}',
region: 'eu-central-1',
profile: 'borrowlend',
logRetentionInDays: 30,
deploymentBucket: {
name: 'borrowlend-serverless-deployments',
},
apiGateway: {
minimumCompressionSize: 1024,
shouldStartNameWithService: true,
},
logs: {
restApi: {
accessLogging: true,
executionLogging: false,
fullExecutionData: false,
},
},
tracing: {
lambda: true,
apiGateway: true,
},
environment,
iamRoleStatements: [
{
Effect: 'Allow',
Action: ['xray:PutTraceSegments', 'xray:PutTelemetryRecords'],
Resource: ['*'],
},
],
},
functions,
package: { individually: true, patterns },
custom,
layers: {
PrismaBorrowlend: {
path: 'lambda-layers/prisma',
compatibleArchitectures: ['arm64'],
compatibleRuntimes: ['nodejs20.x'],
description: 'Lambda layer containing the prisma query engine library for borrowlend',
},
},
};
module.exports = serverlessConfiguration;