Skip to content

Commit

Permalink
oy2-30619 - Configure AWS SDK v2 as a lambda layer (#1534)
Browse files Browse the repository at this point in the history
* add lambda layers for aws sdk v2

* add layer service to deploy script

* remove aws sdk 2 dependency since it will be provided by the layer

* Update deploy.sh

* use awssdkv2 lambda layer across all services

* fix for running locally
  • Loading branch information
bflynn-cms authored Oct 18, 2024
1 parent 676faa2 commit 60f619a
Show file tree
Hide file tree
Showing 16 changed files with 1,016 additions and 160 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ tests/cypress/videos
tests/cypress/screenshots
tests/cypress/fixtures/packageDashboardSPAIDs.json
tests/cypress/fixtures/packageDashboardWaiverNumbers.json
tests/cypress/fixtures/savedID.json
tests/cypress/fixtures/savedID.json
/services/layers/aws-sdk-v2-layer/.serverless
15 changes: 15 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,27 @@
stage=${1:-dev}

install_deps() {
local islayer=false # Flag to track whether we navigated into the nodejs folder

# Check if we're inside a layer directory (layers have a 'nodejs' folder)
if [ -d "nodejs" ]; then
# If we're in a Lambda layer, navigate to the 'nodejs' folder
cd nodejs
islayer=true # Set the flag to true since we navigated into nodejs
fi

if [ "$CI" == "true" ]; then # If we're in a CI system
if [ ! -d "node_modules" ]; then # If we don't have any node_modules (CircleCI cache miss scenario), run npm ci. Otherwise, we're all set, do nothing.
npm ci --legacy-peer-deps
fi
else # We're not in a CI system, let's npm install
npm install --legacy-peer-deps
fi

# If we navigated to the nodejs folder (i.e., for a layer), go back to the root folder
if [ "$islayer" = true ]; then
cd ..
fi
}

deploy() {
Expand All @@ -25,6 +39,7 @@ install_deps
services=(
'ui'
'uploads'
'layers/aws-sdk-v2-layer'
'app-api'
'email'
'one-stream'
Expand Down
2 changes: 1 addition & 1 deletion services/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"version": "1.0.0",
"devDependencies": {
"aws-sdk-client-mock": "^0.5.6",
"aws-sdk": "^2.752.0",
"esbuild": "^0.19.4",
"serverless-dotenv-plugin": "^3.12.2",
"serverless-esbuild": "^1.48.4",
"serverless-offline": "^13.5.0"
},
"dependencies": {
"aws-sdk": "^2.752.0",
"@aws-sdk/client-dynamodb": "^3.43.0",
"@aws-sdk/lib-dynamodb": "^3.454.0",
"cmscommonlib": "file:../common",
Expand Down
4 changes: 2 additions & 2 deletions services/admin/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ plugins:
- serverless-dotenv-plugin
- serverless-s3-bucket-helper
custom:
esbuild:
exclude: []
stage: ${opt:stage, self:provider.stage}
iamPermissionsBoundaryPolicy: ${ssm:/configuration/${self:custom.stage}/iam/permissionsBoundaryPolicy, ssm:/configuration/default/iam/permissionsBoundaryPolicy, ""}
oneMacTableName: onemac-${self:custom.stage}-one
Expand Down Expand Up @@ -42,6 +40,8 @@ provider:
environment:
NODE_OPTIONS: '--enable-source-maps'
oneMacTableName: ${self:custom.oneMacTableName}
layers:
- ${cf:aws-sdk-v2-layer-${self:custom.stage}.AwsSdkV2LambdaLayerQualifiedArn}

functions:

Expand Down
Loading

0 comments on commit 60f619a

Please sign in to comment.