I am looking at this page <https://www.pulumi.com/...
# typescript
b
I am looking at this page https://www.pulumi.com/registry/packages/aws/how-to-guides/aws-ts-apigatewayv2-http-api/ , and more specifically, this chunk of code:
Copy code
exports.handler =  async function(event, context) {
    console.log("EVENT: \n" + JSON.stringify(event, null, 2))
    return {
        statusCode: 200,
        body: "Hello, Pulumi!"
    };
  }
What are the pulumi types for
event
and
context
?
We have a tight type eco system.
Copy code
export const apiHandler = async (
  event: any,
  context: any,
): Promise<any> => {
any
is frowned upon
I can see for the REST api gateway, we have,
event: awsx.classic.apigateway.Request
l
Those are not Pulumi types, afaik? They're request events. I don't know exactly who defines them or where you can look them up, I don't often work in the front end. Maybe w3schools would be a good place to start?
This is the first result back from a search, maybe it's a start? https://aws-lambda-for-python-developers.readthedocs.io/en/latest/02_event_and_context/
If AWSX provides a convenience type, I'd use that. Very handy.
b
a search of my
/node_modules/@pulumi
reveals nothing. I can only conclude there are no Pulumi types defined yet for HTTP ApiGateway.
l
Not for the AWS types, no. There's probably some AWS docs covering what can be in the types. Maybe the AWS client module has the types defined? I don't think it's likely though, since (iirc) they're written in JS, not TS.
b
I will wait for Pulumi to catch up.
l
It's not a Pulumi thing, it's AWS.
There's type mappings for the AWS client in there, you can use those directly.
Just add the dependency to your packages.json.
b
Sorry, which package to be specific?
l
@types/aws-lambda.
b
Thanks.
Looks like I found what I was after, thanks to @little-cartoon-10569
Copy code
import { APIGatewayProxyEventV2WithJWTAuthorizer, APIGatewayProxyResultV2 } from 'aws-lambda';

export const handler = async (
  event: APIGatewayProxyEventV2WithJWTAuthorizer
): Promise<APIGatewayProxyResultV2> => {
  return { statusCode: 200, body: '{}' };
};