-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.ts
93 lines (91 loc) · 2.97 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
import type { AWS } from '@serverless/typescript';
import * as functions from './src/functions';
const serverlessConfiguration: AWS = {
service: '${file(./package.json):name}',
useDotenv: true,
plugins: [
'serverless-webpack',
'serverless-plugin-aws-alerts',
'serverless-domain-manager',
'serverless-offline',
],
provider: {
name: 'aws',
runtime: 'nodejs14.x',
region: '${env:AWS_REGION}' as AWS['provider']['region'],
logRetentionInDays: 30,
stage: '${opt:stage, env:ENV}', // you can override this via the CLI argument
apiGateway: {
minimumCompressionSize: 1024, // Enable gzip compression for responses > 1 KB
shouldStartNameWithService: true,
apiKeys: ['${self:service}-key-${self:provider.stage}'],
usagePlan: {
quota: { limit: 2000, period: 'MONTH' },
throttle: { burstLimit: 10, rateLimit: 5 },
},
},
environment: {
TZ: 'Europe/Berlin',
// Service wide environment variables
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
STAGE: '${self:provider.stage}',
TOGGL_API_TOKEN: '${env:TOGGL_API_TOKEN}',
LEXOFFICE_API_TOKEN: '${env:LEXOFFICE_API_TOKEN}',
CONTENTFUL_SPACE_ID: '${env:CONTENTFUL_SPACE_ID}',
CONTENTFUL_ACCESS_TOKEN: '${env:CONTENTFUL_ACCESS_TOKEN}',
CONTENTFUL_ENVIRONMENT_ID: '${env:CONTENTFUL_ENVIRONMENT_ID, "master"}',
},
lambdaHashingVersion: '20201221',
},
custom: {
enabled: { development: false, production: true },
webpack: { webpackConfig: './webpack.config.js', includeModules: true },
customDomain: {
// https://github.com/amplify-education/serverless-domain-manager
basePath: 'lambda-billing',
domainName: '${env:CUSTOM_DOMAIN}',
createRoute53Record: false,
},
alerts: {
// https://github.com/ACloudGuru/serverless-plugin-aws-alerts
topics: {
alarm: {
topic:
'arn:aws:sns:eu-central-1:009255630476:alert-Topic-N47IM5J07MP7',
},
},
definitions: {
// these defaults are merged with your definitions
functionErrors: { treatMissingData: 'notBreaching', period: 300 },
functionInvocations: {
threshold: 50,
treatMissingData: 'notBreaching',
period: 300,
},
statusCodeErrors: {
metric: 'statusCodeErrors',
threshold: 0,
statistic: 'Sum',
period: 300,
evaluationPeriods: 1,
comparisonOperator: 'GreaterThanThreshold',
pattern: '{$.statusCode != 200}',
treatMissingData: 'missing',
},
},
alarms: [
{
name: 'functionErrors',
enabled: '${self:custom.enabled.${self:provider.stage}}',
},
{ name: 'functionInvocations', enabled: true },
{
name: 'statusCodeErrors',
enabled: '${self:custom.enabled.${self:provider.stage}}',
},
],
},
},
functions,
};
module.exports = serverlessConfiguration;