Skip to content

Show how to setup a Lambda function with shared code using esbuild instead of layers.

Notifications You must be signed in to change notification settings

andmoredev/layerless-esbuild-lambda

Repository files navigation

Repository used as an example for the Drop the layers, bundle up with ESBuild instead article. Update - This includes authentication now. This is all explained in Secure API Gateway with Amazon Cognito using SAM.

Deploy using the SAM CLI

Clone/fork the repository

Clone or fork this repository and push it to your own GitHub account.

Install npm dependencies

npm install

Build and deploy with sam

Logged in to the account you wish to deploy this follow these steps.

1. Build

Build all the artifacts

sam build

2. Deploy

Run sam deploy with the guided flag to capture the necessary information for the deployment.

sam deploy --guided

Deploy in your account using the included GitHub workflows

Clone/fork the repository

Clone or fork this repository and push it to your own GitHub account.

Setup GitHub environment

  1. Create an GitHub environment named sandbox
  2. Add your Pipeline Execution Role (PIPELINE_EXECUTION_ROLE), CloudFormation Execution Role (CLOUDFORMATION_EXECUTION_ROLE) and a target S3 bucket name for the artifacts (ARTIFACTS_BUCKET_NAME) as secrets. Here is an explanation by Chris Ebert on how to set this up.
  3. Setup authentication secrets, you can learn how to set these up by looking at the post mentioned above around securing your APIs with cognito. a. Add COGNITOPOOL_URL you can get this from the Cognito service in the console and append /oauth/token to the url. b. TEST_CLIENT_ID and TEST_CLIENT_SECRET. These values can be found in your user pool client. c. SCOPES should be whatever you set for your resource server to accept.

Run Deployment

In the Actions in GitHub you can select the Deploy to Sandbox Workflow. There will be a button to Run workflow where you can now select the branch you wish to deploy.

GitHub Workflow Execution

About

Show how to setup a Lambda function with shared code using esbuild instead of layers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published