-
Notifications
You must be signed in to change notification settings - Fork 223
/
serverless.yml
218 lines (187 loc) · 7.07 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: earthdata-search
provider:
name: aws
runtime: nodejs18.x
versionFunctions: false
stage: ${opt:stage, 'dev'}
region: us-east-1
endpointType: PRIVATE
memorySize: 128
environment:
NODE_ENV: ${env:NODE_ENV, 'development'}
# Variables for new Encrypted database
databaseEndpoint:
Fn::ImportValue: ${self:provider.stage}-EncryptedDatabaseEndpoint
databasePort:
Fn::ImportValue: ${self:provider.stage}-EncryptedDatabasePort
dbUsername: edsc
dbName: edsc_${self:provider.stage}
colorMapQueueUrl:
Ref: ColorMapsProcessingQueue
tagQueueUrl:
Ref: TagProcessingQueue
cmrOrderingOrderQueueUrl:
Ref: CmrOrderingOrderQueue
catalogRestQueueUrl:
Ref: CatalogRestOrderQueue
harmonyQueueUrl:
Ref: HarmonyOrderQueue
swodlrQueueUrl:
Ref: SwodlrOrderQueue
userDataQueueUrl:
Ref: UserDataQueue
obfuscationSpin: ${self:custom.variables.obfuscationSpin}
obfuscationSpinShapefiles: ${self:custom.variables.obfuscationSpinShapefiles}
orderDelaySeconds: ${self:custom.variables.orderDelaySeconds}
useCache: ${self:custom.variables.useCache}
configSecretId:
Fn::ImportValue: ${self:provider.stage}-DbPasswordSecret
collectionCapabilitiesLambda: ${self:custom.siteName}-generateCollectionCapabilityTags
NODE_OPTIONS: '--enable-source-maps'
# Redis cache configuration
cacheHost:
Fn::ImportValue: ${self:provider.stage}-ElastiCacheEndpoint
cachePort:
Fn::ImportValue: ${self:provider.stage}-ElastiCachePort
cacheKeyExpireSeconds: ${self:custom.variables.cacheKeyExpireSeconds}
vpc:
securityGroupIds:
- Fn::ImportValue: ${self:provider.stage}-LambdaSecurityGroup
subnetIds:
- ${env:SUBNET_ID_A, 'subnetIdA'}
- ${env:SUBNET_ID_B, 'subnetIdB'}
iam:
role:
Fn::ImportValue: ${self:provider.stage}-EDSCServerlessAppRole
# Prevent Serverless from attempting to modify the deployment bucket policy as NGAP does not allow it
deploymentBucket:
skipPolicySetup: true
# Deprecation warning: Starting with next major version, API Gateway naming will be changed from "{stage}-{service}" to "{service}-{stage}".
# Set "provider.apiGateway.shouldStartNameWithService" to "true" to adapt to the new behavior now.
# More Info: https://www.serverless.com/framework/docs/deprecations/#AWS_API_GATEWAY_NAME_STARTING_WITH_SERVICE
# Setup apiGateway to be able to return image/png responses for `scale` lambda thumbnails
apiGateway:
shouldStartNameWithService: true
binaryMediaTypes: 'image/png'
plugins:
- serverless-esbuild
- serverless-finch
- serverless-step-functions
- serverless-plugin-split-stacks
- serverless-plugin-log-subscription
- serverless-plugin-ifelse
- serverless-offline
#
# Lambda Functions
#
functions: ${file(./serverless-configs/${self:provider.name}-functions.yml)}
#
# Additional AWS Resources
#
resources: ${file(./serverless-configs/${self:provider.name}-resources.yml)}
#
# Step functions to manage order status jobs
#
stepFunctions: ${file(./serverless-configs/${self:provider.name}-step-functions.yml)}
# Package each lambda into individual zip files. This reduces the size of
# each lambda but increases the complexity of the compilation process slightly
package:
individually: true
patterns:
# TODO this adds migrations to every lambda package, we need to only provide them to the migrateDatabase function
- 'migrations/**'
configValidationMode: error
custom:
siteName: earthdata-search-${self:provider.stage}
infrastructureStackName: earthdata-search-infrastructure-${self:provider.stage}
serverlessIfElse:
# When invoking an offline lambda with `npm run invoke-local` this condition will disable serverless components that need to import or reference cloudformation values
- If: '"${self:provider.stage}" == "invokeLocal"'
Exclude:
- provider.environment.databaseEndpoint
- provider.environment.databasePort
- provider.environment.cacheHost
- provider.environment.cachePort
- provider.environment.colorMapQueueUrl
- provider.environment.tagQueueUrl
- provider.environment.cmrOrderingOrderQueueUrl
- provider.environment.catalogRestQueueUrl
- provider.environment.harmonyQueueUrl
- provider.environment.swodlrQueueUrl
- provider.environment.userDataQueueUrl
- provider.environment.configSecretId
- provider.vpc
- provider.iam
- functions.submitCatalogRestOrder.environment.updateOrderStatusStateMachineArn
- functions.submitCmrOrderingOrder.environment.updateOrderStatusStateMachineArn
- functions.submitHarmonyOrder.environment.updateOrderStatusStateMachineArn
- functions.submitSwodlrOrder.environment.updateOrderStatusStateMachineArn
variables:
# Default values for environment variables used to set environment variables
cacheKeyExpireSeconds: ${env:CACHE_KEY_EXPIRE_SECONDS, '84000'}
obfuscationSpin: ${env:OBFUSCATION_SPIN, ''}
obfuscationSpinShapefiles: ${env:OBFUSCATION_SPIN_SHAPEFILES, ''}
orderDelaySeconds: ${env:ORDER_DELAY_SECONDS, '1'}
useCache: ${env:USE_CACHE, 'false'}
cloudfrontToCloudwatchBucketPrefixApi:
Fn::Join:
- '/'
- - 'cloudfront/AWSLogs'
- !Ref 'AWS::AccountId'
- ${self:provider.region}
- 'search_${self:provider.stage}_api/'
cloudfrontToCloudwatchBucketPrefixS3:
Fn::Join:
- '/'
- - 'cloudfront/AWSLogs'
- !Ref 'AWS::AccountId'
- ${self:provider.region}
- 'search_${self:provider.stage}_s3/'
# Finch (S3 sync plugin)
client:
bucketName: ${self:custom.siteName}
distributionFolder: static/dist
objectHeaders:
index.html:
- name: Cache-Control
value: no-cache
'*.css':
- name: Cache-Control
value: 'max-age=31536000'
'*.js':
- name: Cache-Control
value: 'max-age=31536000'
assets/:
- name: Cache-Control
value: 'max-age=31536000'
# Prevent the plugin from attempting to change the bucket policy
manageResources: false
# Default is 3000 so to avoid conflicts with rails applications we'll define a new port
serverless-offline:
httpPort: 3001
reloadHandler: true
# Uncomment useInProcess to enable in-process run mode
# https://github.com/dherault/serverless-offline#run-modes
# useInProcess: true
# Don't minify the build in development or when invoking lambdas locally
minifyBuild:
invokeLocal: false
dev: false
sit: true
uat: true
prod: true
# Serverless esbuild configurations
esbuild:
loader:
.svg: text
external: ['knex', 'pg', 'sharp']
bundle: true
minify: ${self:custom.minifyBuild.${self:provider.stage}}
watch:
ignore: ['.esbuild', 'dist', 'node_modules', '.build', 'static', '*.test.js']
# Manage resource count (Maximum of 200) by splitting up the cloudformation templates
splitStacks:
perFunction: true
logSubscription:
enabled: true
destinationArn: ${env:LOG_DESTINATION_ARN, ''}