sparse-intern-71089
09/11/2023, 5:25 PMelegant-gigabyte-8733
09/11/2023, 5:27 PMbillowy-army-68599
quiet-crayon-85132
09/11/2023, 5:47 PM// 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}`,
event,
context,
}),
};
},
});
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;
// Pulumi.yml
name: api
description: A minimal AWS TypeScript Pulumi program
main: src/index.ts
runtime: nodejs
quiet-crayon-85132
09/11/2023, 5:48 PM2023-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"
]
}
quiet-crayon-85132
09/11/2023, 5:51 PM{
"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"
}
}
billowy-army-68599
quiet-crayon-85132
09/11/2023, 5:56 PMquiet-crayon-85132
09/11/2023, 6:15 PMquiet-crayon-85132
09/11/2023, 6:16 PM