forked from venkatram090993/RareCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yaml
141 lines (135 loc) · 4.51 KB
/
serverless.yaml
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
service: rarecamp${{env:SERVERLESS_SERVICE_SUFFIX, ''}}
provider:
name: aws
# NOTE: serverless-offline doesn't work for nodejs14.x
# See https://github.com/lambci/docker-lambda/issues/329
runtime: ${{env:LAMBDA_RUNTIME, 'nodejs12.x'}}
memorySize: 128
timeout: 29
logRetentionInDays: ${{self:custom.stages.${{self:provider.stage}}.logRetentionInDays}}
stage: ${{opt:stage, env:NODE_ENV, 'development'}}
profile: ${{self:custom.stageConfig.profile}}
region: us-west-2
variableSyntax: "\\${{([ ~:a-zA-Z0-9._@\\'\",\\-\\/\\(\\)]+?)}}"
logs:
restApi:
format: '{ "requestId":"$context.requestId", "ip": "$context.identity.sourceIp", "caller":"$context.identity.caller", "user":"$context.identity.user", "requestTime":"$context.requestTime", "httpMethod":"$context.httpMethod", "resourcePath":"$context.resourcePath", "status":"$context.status", "protocol":"$context.protocol", "responseLength":"$context.responseLength" }'
level: INFO # TODO: add custom field for setting this; default to ERROR for prod
environment:
USER_TABLE: !Ref UserTable
DISEASE_TABLE: !Ref DiseaseTable
PROGRAM_TABLE: !Ref ProgramTable
PROJECT_TABLE: !Ref ProjectTable
# Enable connection reuse for AWS SDK for instant performance boost
# https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
package:
individually: true
plugins:
- serverless-dotenv-plugin
- serverless-domain-manager
- serverless-prune-plugin
- serverless-plugin-tracing
- serverless-iam-roles-per-function
- serverless-webpack
- serverless-stack-output
- serverless-cloudside-plugin
- serverless-plugin-aws-alerts
- '@brettstack/serverless-amplify-plugin'
- serverless-dynamodb-local
- serverless-offline
- serverless-stack-termination-protection
custom:
stages:
development:
profile: ${{env:AWS_PROFILE}}
logRetentionInDays: 1
amplify:
api:
domainEnabled: false
alarms:
notificationEmail: ${{env:ALARMS_NOTIFICATION_EMAIL}}
staging:
profile: rarecamp_staging
logRetentionInDays: 3
api:
domainEnabled: false
domainName: staging.api.example.com
validationDomain: example.com
amplify:
# domainName: staging.example.com
# branch: staging
alarms:
notificationEmail: [email protected]
production:
profile: rarecamp_prod
logRetentionInDays: 14
pointInTimeRecoveryEnabled: true
api:
domainEnabled: false
domainName: api.example.com
validationDomain: example.com
amplify:
# domainName: example.com
alarms:
notificationEmail: [email protected]
stageConfig: ${{self:custom.stages.${{self:provider.stage}}}}
prune:
automatic: true
number: 10
customDomain:
domainName: ${{self:custom.stageConfig.api.domainName, ''}}
certificateName: ${{self:custom.stageConfig.api.domainName, ''}}
enabled: ${{self:custom.stageConfig.api.domainEnabled, false}}
# createRoute53Record: ${{self:custom.stageConfig.api.isDomainRoute53, false}}
serverless-offline:
httpPort: 4911
noPrependStageInUrl: true
useChildProcesses: true # hack to get watching working
useSeparateProcesses: true
amplify:
isManual: true
domainName: ${{self:custom.stageConfig.amplify.domainName, ''}}
buildSpecValues:
artifactBaseDirectory: packages/ui/out
preBuildWorkingDirectory: packages/ui
buildCommandEnvVars:
prefix: 'NEXT_PUBLIC_'
allow:
- ApiEndpoint
- CognitoIdentityPoolId
- CognitoUserPoolId
- CognitoUserPoolClientId
webpack:
webpackConfig: ./functions.webpack.config.js
output:
file: ./stack-outputs.json
alerts:
dashboards: true
nameTemplate: $[functionName]-$[metricName]-Alarm
topics:
alarm:
topic: ${{self:service}}-${{self:provider.stage}}-alarm
notifications:
- protocol: email
endpoint: ${{self:custom.stageConfig.alarms.notificationEmail}}
# TODO: Add short and long alarms for each
alarms:
- functionThrottles
- functionErrors
- functionInvocations
- functionDuration
serverlessTerminationProtection:
stages:
- staging
- production
dynamodb:
stages:
- development
start:
dbPath: '.dynamodb'
migrate: false
functions: ${{file(templates/functions.yml)}}
resources:
- ${{file(templates/resources.yml)}}
- ${{file(templates/dynamodb.yml)}}