-
Notifications
You must be signed in to change notification settings - Fork 258
Open
Copy link
Labels
kind/bugSome behavior is incorrect or out of specSome behavior is incorrect or out of spec
Description
What happened?
In the Pulumi docs under:
Infrastructure as Code → Clouds → AWS → Guides → Lambda
the TypeScript example for creating a RestAPI with an inline Lambda eventHandler appears to be incorrect or out of date. The documented code is:
import * as apigateway from "@pulumi/aws-apigateway";
import { APIGatewayProxyEvent, Context } from "aws-lambda";
const api = new apigateway.RestAPI("api", {
routes: [
{
path: "/api",
eventHandler: async (event: APIGatewayProxyEvent, context: Context) => {
return {
statusCode: 200,
body: JSON.stringify({
eventPath: event.path,
functionName: context.functionName,
})
};
},
},
],
});
When implementing this example in TypeScript, the following error occurs:
Type '(event: APIGatewayProxyEvent, context: Context) => Promise<{ statusCode: number; body: string; }>'
is not assignable to type 'Input<Function> | undefined'.ts(2322)
input.d.ts(103, 5): The expected type comes from property 'eventHandler' which is declared here on type 'RouteArgs'
It appears that the eventHandler field in RouteArgs no longer accepts a typed inline function of this shape. This suggests either:
- The docs show an outdated API, or
- The type declaration for eventHandler is too restrictive / inconsistent with intended usage.
Example
- Create a Pulumi TypeScript project.
- Install @pulumi/aws-apigateway and aws-lambda types.
- Paste the docs’ example code above.
- Run tsc or pulumi up.
Output of pulumi about
CLI
Version 3.210.0
Go Version go1.25.5
Go Compiler gc
Plugins
KIND NAME VERSION
language nodejs 3.210.0
Host
OS darwin
Version 15.6.1
Arch arm64
This project is written in nodejs: executable='/Users/rodrigosannicolas/.nvm/versions/node/v22.18.0/bin/node' version='v22.18.0'
Dependencies:
NAME VERSION
typescript 5.9.3
@pulumi/aws 6.83.2
@pulumi/pulumi 3.210.0
esbuild 0.24.2
@aws-sdk/client-dynamodb 3.946.0
@aws-sdk/client-lambda 3.946.0
@aws-sdk/lib-dynamodb 3.946.0
@pulumi/aws-apigateway 3.0.0
@types/aws-lambda 8.10.159
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
Metadata
Metadata
Assignees
Labels
kind/bugSome behavior is incorrect or out of specSome behavior is incorrect or out of spec