Skip to content

Instantly share code, notes, and snippets.

@CharlieGreenman
Created April 21, 2024 23:49
Show Gist options
  • Save CharlieGreenman/ec8ca79c42bd96b7dc3387adcb190ea4 to your computer and use it in GitHub Desktop.
Save CharlieGreenman/ec8ca79c42bd96b7dc3387adcb190ea4 to your computer and use it in GitHub Desktop.
Typescript x Node Lambda Layers - Syntax for creating a lambda layer that uses a makefile to build typescript
# file path of makefile: src/functions/shared/Makefile
build-SharedLambdaLayer:
rm -Rf node_modules
npm install
npm run build
cp -rf dist/* ${ARTIFACTS_DIR}
npm prune --production
cp -rf node_modules ${ARTIFACTS_DIR}
SharedLambdaLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: shared-lambda-layer
Description: Shared Lambda Layer
ContentUri: src/functions/shared
CompatibleRuntimes:
- nodejs20.x
Metadata:
BuildMethod: makefile
@CharlieGreenman
Copy link
Author

Note, aws lambda will use index.handler by default, so even though AWS::Serverless::LayerVersion does not allow an index handler, as long as code in index.js this will work 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment