Skip to main content

Search the Dev Center

Search tutorials, templates, examples, and more.

Building and bundling Lambda dependencies

Pulumi program to demonstrate how to install dependencies and package up code for deployment to AWS Lambda functions

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set aws-ts-multi-language-lambda
cd pulumi-examples/aws-ts-multi-language-lambda

This example shows how to install dependencies and build multiple Lambda functions in different languages and then deploy the results.

You don’t need to install any languages other than Node.js because we’ll use Docker containers to build the code.

Prerequisites#

  1. Install Pulumi
  2. Configure AWS credentials
  3. Install Node.js
  4. Install Docker

Deploying the example#

  1. Create a new stack:

    Terminal window
    pulumi stack init dev
  2. Set the AWS region to deploy into:

    Terminal window
    pulumi config set aws:region us-west-2
  3. Install dependencies:

    Terminal window
    npm install
  4. Deploy the stack:

    Terminal window
    pulumi up

    Once all the resources have deployed, you can run the Lambdas and see the outputs.

Cleaning up#

Once you’re finished, destroy the resources and remove the stack:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.