for example: ```const api = new awsx.apigateway.AP...
# typescript
e
for example:
Copy code
const api = new awsx.apigateway.API(`airship-api-${NODE_ENV}`, {
  routes: [
    {
      path: "/",
      method: "GET",
      eventHandler: async (event: APIGatewayProxyEvent) => ({
        statusCode: HttpStatus.OK,
        body: "Hello, API Gateway V4!",
      }),
    },
    {
      path: "/api/named_users/associate",
      method: "POST",
      eventHandler: async (event: APIGatewayProxyEvent): Promise<any> => ({
        statusCode: HttpStatus.OK,
        body: JSON.stringify(await handleSetNamedUser(event)),
        isBase64Encoded: false,
      }),
    },
    {
      path: "/api/channels/tags",
      method: "POST",
      eventHandler: async (event: APIGatewayProxyEvent) => ({
        statusCode: HttpStatus.OK,
        body: JSON.stringify(await handleSetTags(event)),
        isBase64Encoded: false,
      }),
    },
  ],
});
I want to make something if
c
There are a few bits to API gateway v2. You need the lambda, an integration and a route. AWSX (Pulumi Crosswalk in their docs) is a higher level API which creates a few different things under the covers for you.
Copy code
const lambda = new aws.lambda.CallbackFunction(`${name}-lambda`, {
            callback: async (event: APIGatewayProxyEvent): Promise<any> => ({
        statusCode: HttpStatus.OK,
        body: JSON.stringify(await handleSetNamedUser(event)),
        isBase64Encoded: false,
      }),
        })

const integration = new aws.apigatewayv2.Integration(
    `${name}-integration`,
    {
        apiId,
        integrationMethod: 'POST',
        integrationType: 'AWS_PROXY',
        integrationUri: lambda.invokeArn,
    },
)

new aws.apigatewayv2.Route(
    `${name}-route`,
    {
        apiId,
        routeKey: 'api/named_users/associate',
        authorizationType: authorizerId ? 'JWT' : 'NONE',
        authorizerId: authorizerId,
        target: pulumi.interpolate`integrations/${integration.id}`,
    },
)
I pull the above into a component resource called api-route which creates all of those things, plus a log group etc
🙌 1
e
Thanks @curved-pharmacist-41509, although I'm still not very clear on how to implement the idea you gave me
c
Each route needs those 3 resources
You create the api gateway, then you attach routes to them
Routes have an integration, you are using a lambda integration
It matches the AWS docs and way you configure things through the console much closer than the crosswalk approach
e
Here I have an example with V2 but I still don't see very well how to implement two routes that work in the same api https://github.com/pulumi/examples/blob/master/aws-ts-apigatewayv2-http-api/index.ts
c
That is using the quick start which is a single route
There are two ways to do it
e
Thanks @curved-pharmacist-41509, I'll let you know when I do.🙌