We are attempting to deploy an AWS Lambda using pu...
# typescript
We are attempting to deploy an AWS Lambda using pulumi in typescript https://www.pulumi.com/registry/packages/aws/api-docs/lambda/function/ . We have an npm package we want to use in the lambda code, but are having a tough time getting pulumi to deploy the function with the package. Are there any examples available or pointers on how to get pulumi to do npm install and bundle the lambda code with packages?
What error are you getting when attempting to deploy?
we are attempting a base case of a lambda that has the package "uuid" installed.
Copy code
// src/index.ts
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import { v4 as uuid } from "uuid";

const getLambda = new aws.lambda.CallbackFunction("getBucket", {
  callback: async (event, context, cb) => {
    const id = uuid();

    return {
      statusCode: 200,
      body: JSON.stringify({
        message: `Hello, API Gateway!. ${id}`,

const api = new awsx.classic.apigateway.API(`api-gateway`, {
  routes: [
      path: "/bucket",
      method: "GET",
      eventHandler: getLambda,

// Export the auto-generated API Gateway base URL
export const url = api.url;
Copy code
// Pulumi.yml
name: api
description: A minimal AWS TypeScript Pulumi program
main: src/index.ts
runtime: nodejs
and we get this error in the cloudwatch logs when invoking that lambda
Copy code
2023-09-11T17:29:43.215Z	undefined	ERROR	Uncaught Exception 	
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'uuid'\nRequire stack:\n- /var/task/__index.js\n- /var/runtime/index.mjs",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module 'uuid'",
        "Require stack:",
        "- /var/task/__index.js",
        "- /var/runtime/index.mjs",
        "    at _loadUserApp (file:///var/runtime/index.mjs:1061:17)",
        "    at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1093:21)",
        "    at async start (file:///var/runtime/index.mjs:1256:23)",
        "    at async file:///var/runtime/index.mjs:1262:1"
and the package.json
Copy code
  "name": "@demo/pulumi-api",
  "private": true,
  "version": "1.0.0",
  "dependencies": {
    "@pulumi/aws": "^5.42.0",
    "@pulumi/awsx": "^1.0.4",
    "@pulumi/pulumi": "^3.78.0",
    "nanoid": "3.3.1",
    "uuid": "^8.3.2"
  "devDependencies": {
    "@types/node": "^18",
    "@types/uuid": "^9.0.0"
sure thing thank you
gah so upon seeing open issues we found this one, we also use pnpm 😕 https://github.com/pulumi/pulumi/issues/11751#issuecomment-1646954783
seems like this PR was ready to go: https://github.com/pulumi/pulumi/pull/13055