This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.ts
94 lines (90 loc) · 2.52 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
import type { AWS } from '@serverless/typescript'
import { execSync } from 'child_process'
import env from './src/env/env'
const SERVICE_NAME = 'postal-vote-server'
const getVersion = (): string => {
const hash = execSync('git rev-parse --short HEAD', { encoding: 'utf-8' })
return `${(new Date()).toISOString().replace(/-/g, '').replace(/\..*/, '')
.replace(/:/g, '')
.replace('T', '.')}.${hash.trim()}`
}
const serverlessConfiguration: AWS = {
service: SERVICE_NAME,
frameworkVersion: '3',
custom: {
webpack: {
webpackConfig: './webpack.config.js',
includeModules: {
forceExclude: [
// When the aws-sdk v3 is included in the lambda environment, we should exclude all of it
'@aws-sdk/types',
],
},
packagerOptions: {
scripts: [
// Remove unused code that the bundler misses
'rm -rf node_modules/@types',
],
},
},
'serverless-offline': {
httpPort: 8001,
websocketPort: 8002,
lambdaPort: 8003,
},
'serverless-offline-ses-v2': {
port: 8005,
},
},
plugins: [
'serverless-webpack',
'serverless-offline',
'serverless-offline-ses-v2',
],
provider: {
name: 'aws',
stage: env.STAGE,
runtime: 'nodejs14.x',
region: 'eu-west-1',
apiGateway: {
minimumCompressionSize: 1024,
shouldStartNameWithService: true,
},
httpApi: {
payload: '2.0',
cors: true,
},
environment: {
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
STAGE: env.STAGE,
VERSION: getVersion(),
},
memorySize: 128,
timeout: 10,
iam: {
role: {
statements: [
{
Effect: 'Allow',
Action: [
'ses:SendRawEmail',
],
Resource: '*',
},
],
},
},
},
functions: {
apiRouter: {
handler: 'src/submit.main',
events: [{
httpApi: {
method: 'POST',
path: '/submit',
},
}],
},
},
}
module.exports = serverlessConfiguration