This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
218 lines (218 loc) · 9.69 KB
/
serverless.yml
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
service: api-notarise-healthcerts
configValidationMode: error
provider:
name: aws
runtime: nodejs18.x
memorySize: 256
timeout: 30 # optional, in seconds, default is 6
stage: ${opt:stage, "dev"}
region: ${opt:region, "ap-southeast-1"}
stackName: ${self:service}-${self:provider.stage}
versionFunctions: false
environment:
AWS_XRAY_CONTEXT_MISSING: LOG_ERROR
STAGE: ${self:provider.stage}
DEBUG: "*,-follow-redirects"
tracing:
lambda: true
apiGateway: true
apiGateway:
metrics: true
usagePlan:
quota:
limit: 100000
offset: 0
period: DAY
throttle:
burstLimit: 200
rateLimit: 100
iam:
role:
permissionsBoundary: "arn:aws:iam::${self:custom.accountId}:policy/GCCIAccountBoundary"
statements:
- Effect: "Allow"
Action:
- kms:Decrypt
Resource: ${self:custom.KMS_ARN}
- Effect: Allow
Action: ["kms:GenerateDataKey"]
Resource: "arn:aws:kms:${self:provider.region}:${self:custom.accountId}:key/${env:SNS_KMS_KEY_ID, 'PLACEHOLDER'}"
- Effect: "Allow"
Action:
- ssm:GetParameters
Resource:
- "arn:aws:ssm:${self:provider.region}:${self:custom.accountId}:parameter/serverless/SIGNING_EU_QR_PRIVATE_KEY"
- "arn:aws:ssm:${self:provider.region}:${self:custom.accountId}:parameter/serverless/SIGNING_EU_QR_PUBLIC_KEY"
- "arn:aws:ssm:${self:provider.region}:${self:custom.accountId}:parameter/serverless/api-notarise-healthcerts/GPAY_COVID_CARD_PRIVATE_KEY"
- "arn:aws:ssm:${self:provider.region}:${self:custom.accountId}:parameter/serverless/WHITELIST_NRICS"
- "arn:aws:ssm:${self:provider.region}:${self:custom.accountId}:parameter/serverless/api-resident/HASH_SALT"
- Effect: Allow
Action: ["sns:Publish"]
Resource: "arn:aws:sns:${self:provider.region}:${self:custom.accountId}:healthcert"
- Effect: Allow
Action: ["sns:Publish"]
Resource: "arn:aws:sns:${self:provider.region}:${self:custom.accountId}:api-spm-*-spm-healthcert-topic"
deploymentBucket:
name: notarise-serverless-deployment
logs:
restApi:
accessLogging: true
executionLogging: true
fullExecutionData: false
roleManagedExternally: true
level: INFO
deploymentMethod: direct
functions:
notarisePdtV2:
provisionedConcurrency: ${self:custom.concurrency.${self:provider.stage}, self:custom.concurrency.other}
environment:
AUTHORIZED_ISSUERS_API_KEY: ${self:custom.ssm.AUTHORIZED_ISSUERS_API_KEY}
AUTHORIZED_ISSUERS_API_URL: ${self:custom.ssm.AUTHORIZED_ISSUERS_API_URL}
AUTHORIZED_ISSUERS_MAP: ${self:custom.ssm.AUTHORIZED_ISSUERS_MAP}
ETHEREUM_NETWORK: ${self:custom.ethereumConfig.${self:provider.stage}, self:custom.ethereumConfig.stg}
GPAY_COVID_CARD_ENABLED: ${self:custom.ssm.GPAY_COVID_CARD_ENABLED}
GPAY_COVID_CARD_ISSUER_ID: ${self:custom.ssm.GPAY_COVID_CARD_ISSUER_ID}
GPAY_COVID_CARD_ISSUER: ${self:custom.ssm.GPAY_COVID_CARD_ISSUER}
GPAY_COVID_CARD_PRIVATE_KEY: ${self:custom.ssm.GPAY_COVID_CARD_PRIVATE_KEY}
HEALTH_CERT_NOTIFICATION_ENABLED: ${self:custom.ssm.HEALTH_CERT_NOTIFICATION_ENABLED}
HEALTH_CERT_NOTIFICATION_TOPIC_ARN: ${self:custom.ssm.HEALTH_CERT_NOTIFICATION_TOPIC_ARN}
INFURA_API_KEY: ${self:custom.ssm.INFURA_API_KEY}
OFFLINE_QR_ENABLED: ${self:custom.ssm.OFFLINE_QR_ENABLED}
RESIDENT_API_KEY: ${self:custom.ssm.RESIDENT_API_KEY}
RESIDENT_API_URL: ${self:custom.ssm.RESIDENT_API_URL}
REVOCATION_OCSP: ${self:custom.ssm.REVOCATION_OCSP}
SIGNING_DID_KEY: ${self:custom.ssm.SIGNING_DID_KEY}
SIGNING_DID_NAME: ${self:custom.ssm.SIGNING_DID_NAME}
SIGNING_DID_PRIVATE_KEY: ${self:custom.ssm.SIGNING_DID_PRIVATE_KEY}
SIGNING_DID: ${self:custom.ssm.SIGNING_DID}
SIGNING_DNS_DID_LOCATION: ${self:custom.ssm.SIGNING_DNS_DID_LOCATION}
SIGNING_EU_QR_NAME: ${self:custom.ssm.SIGNING_EU_QR_NAME}
SIGNING_EU_QR_PRIVATE_KEY: ${self:custom.ssm.SIGNING_EU_QR_PRIVATE_KEY}
SIGNING_EU_QR_PUBLIC_KEY: ${self:custom.ssm.SIGNING_EU_QR_PUBLIC_KEY}
SLACK_WEBHOOK_URL: ${self:custom.ssm.SLACK_WEBHOOK_URL}
TRANSIENT_STORAGE_API_KEY: ${self:custom.ssm.TRANSIENT_STORAGE_API_KEY}
TRANSIENT_STORAGE_URL: ${self:custom.ssm.TRANSIENT_STORAGE_URL}
USE_API_AUTHORISED_ISSUER: ${self:custom.ssm.USE_API_AUTHORISED_ISSUER}
WHITELIST_NRICS: ${self:custom.ssm.WHITELIST_NRICS}
handler: src/functionHandlers/notarisePdt/v2/handler.handler
events:
- http:
path: /v2/notarise/pdt
method: post
private: true
revokePdtHealthCert:
provisionedConcurrency: ${self:custom.concurrency.${self:provider.stage}, self:custom.concurrency.other}
environment:
REVOCATION_OCSP: ${self:custom.ssm.REVOCATION_OCSP}
REVOCATION_OCSP_API_KEY: ${self:custom.ssm.REVOCATION_OCSP_API_KEY}
handler: src/functionHandlers/revokePdtHealthCert/handler.handler
events:
- http:
path: /v2/notarise/revoke
method: post
private: true
custom:
associateWaf:
name: ${env:WAF_NAME, ''}
version: V2
serverless-offline:
lambdaPort: 4002
httpPort: 4000
# right now, when developing with api-transient-storage, there is a clash as both repos use serverless-s3-local, defaulting to port 4569
s3:
port: 4701
concurrency:
production: 0
stg: 0
other: 0
vpcDiscovery:
vpcName: "${env:VPC_NAME}"
subnets:
- tagKey: Name
tagValues:
- "notarize-${self:custom.subnetEnvName.${self:provider.stage}, self:custom.subnetEnvName.stg}-application-private-*"
securityGroups:
- names:
- "default-application-vpc-*"
subnetEnvName:
stg: "stg"
production: "prd"
customDomainList:
production: "api-notarise-healthcerts.aws.notarise.gov.sg"
stg: "api-notarise-healthcerts.stg.notarise.io"
other: "api-notarise-healthcerts-${self:provider.stage}.stg.notarise.io"
customDomain:
domainName: "${self:custom.customDomainList.${self:provider.stage}, self:custom.customDomainList.other}"
basePath: ""
stage: ${self:provider.stage}
createRoute53Record: true
endpointType: regional
autoDomain: true
KMS_ARN: ${env:KMS_ARN, "PLACEHOLDER_ARN"}
ethereumConfig:
stg: "goerli"
production: "homestead"
ssm:
# reason why some variable is empty because in sls3 it throw error if the variable does not exist
# but these vars is loaded from withSSm.ts file dynamically
# so just empty placeholder
AUTHORIZED_ISSUERS_API_KEY: ${ssm:/serverless/api-notarise-healthcerts/AUTHORIZED_ISSUERS_API_KEY, ""}
AUTHORIZED_ISSUERS_API_URL: ${ssm:/serverless/api-notarise-healthcerts/AUTHORIZED_ISSUERS_API_URL, ""}
AUTHORIZED_ISSUERS_MAP: ${ssm:/serverless/api-notarise-healthcerts/AUTHORIZED_ISSUERS_MAP, "development"}
GPAY_COVID_CARD_ENABLED: ${ssm:/serverless/api-notarise-healthcerts/GPAY_COVID_CARD_ENABLED, ""}
GPAY_COVID_CARD_ISSUER_ID: ${ssm:/serverless/api-notarise-healthcerts/GPAY_COVID_CARD_ISSUER_ID, ""}
GPAY_COVID_CARD_ISSUER: ${ssm:/serverless/api-notarise-healthcerts/GPAY_COVID_CARD_ISSUER, ""}
GPAY_COVID_CARD_PRIVATE_KEY: ""
HEALTH_CERT_NOTIFICATION_ENABLED: ${ssm:/serverless/api-notarise-healthcerts/HEALTH_CERT_NOTIFICATION_ENABLED, ""}
HEALTH_CERT_NOTIFICATION_TOPIC_ARN: ${ssm:/serverless/api-notarise-healthcerts/HEALTH_CERT_NOTIFICATION_TOPIC_ARN, ""}
INFURA_API_KEY: ${ssm:/serverless/INFURA_API_KEY, ""}
OFFLINE_QR_ENABLED: ${ssm:/serverless/OFFLINE_QR_ENABLED, ""}
RESIDENT_API_KEY: ${ssm:/serverless/api-notarise-healthcerts/RESIDENT_API_KEY, ""}
RESIDENT_API_URL: ${ssm:/serverless/api-notarise-healthcerts/RESIDENT_API_URL, ""}
REVOCATION_OCSP_API_KEY: ${ssm:/serverless/api-notarise-healthcerts/REVOCATION_OCSP_API_KEY, ""}
REVOCATION_OCSP: ${ssm:/serverless/api-notarise-healthcerts/REVOCATION_OCSP, ""}
SIGNING_DID_KEY: ${ssm:/serverless/api-notarise-healthcerts/SIGNING_DID_KEY, ""}
SIGNING_DID_NAME: ${ssm:/serverless/api-notarise-healthcerts/SIGNING_DID_NAME, ""}
SIGNING_DID_PRIVATE_KEY: ${ssm:/serverless/api-notarise-healthcerts/SIGNING_DID_PRIVATE_KEY, ""}
SIGNING_DID: ${ssm:/serverless/api-notarise-healthcerts/SIGNING_DID, ""}
SIGNING_DNS_DID_LOCATION: ${ssm:/serverless/api-notarise-healthcerts/SIGNING_DNS_DID_LOCATION, ""}
SIGNING_EU_QR_NAME: ${ssm:/serverless/api-notarise-healthcerts/SIGNING_EU_QR_NAME, ""}
SIGNING_EU_QR_PRIVATE_KEY: ""
SIGNING_EU_QR_PUBLIC_KEY: ""
SLACK_WEBHOOK_URL: ${ssm:/serverless/SLACK_WEBHOOK_URL, ""}
TRANSIENT_STORAGE_API_KEY: ${ssm:/serverless/api-notarise-healthcerts/TRANSIENT_STORAGE_API_KEY, ""}
TRANSIENT_STORAGE_URL: ${ssm:/serverless/api-notarise-healthcerts/TRANSIENT_STORAGE_URL, ""}
USE_API_AUTHORISED_ISSUER: ${ssm:/serverless/api-notarise-healthcerts/USE_API_AUTHORISED_ISSUER, ""}
WHITELIST_NRICS: ""
# End of hack on env
accountId: ${file(./src/serverlessConfig.js):getAccountId}
bundle:
externals:
- ethers
- "@govtechsg/oa-verify"
caching: false
esbuild: true
rawFileExtensions:
- txt
- html
serverless-offline-ssm:
stages:
- offline
- dev
serverlessTerminationProtection:
stages:
- production
- stg
# breaking update to serverless>=2.26.0 to use .env files
# https://www.serverless.com/framework/docs/environment-variables/
useDotenv: true
plugins:
- serverless-bundle
- serverless-offline-ssm
- serverless-domain-manager
- serverless-attach-permission-boundary
- "@govtechsg/serverless-selective-functions"
- serverless-vpc-discovery
- serverless-offline
- serverless-stack-termination-protection
- serverless-associate-waf