Hey everyone! Pulumi newbie here :wave: Does anybo...
# general
b
Hey everyone! Pulumi newbie here 👋 Does anybody know how I could add a lambda function to an existing API Gateway? My code so far is below. It's creating the function, but I'm getting an internal error when I try to curl it using the api gateway url. Looking at the AWS console my suspicion is that I need to add an API Gateway Trigger to the function but I couldn't figure out how to do that so far.
Copy code
const lambdaFunction = new aws.lambda.CallbackFunction("foo-function", {
  callback: handler,
  runtime: "nodejs14.x",
})

const apis = await aws.apigatewayv2.getApis({ name: "my-existing-api" })
const apiId = apis.ids[0]
const api = await aws.apigatewayv2.getApi({ apiId })

const integration = new aws.apigatewayv2.Integration("foo-integration", {
  apiId: api.id,
  integrationType: "AWS_PROXY",
  integrationMethod: "POST",
  integrationUri: lambdaFunction.invokeArn,
})

const route = new aws.apigatewayv2.Route("foo-route", {
  apiId: api.id,
  routeKey: "POST /foo",
  target: pulumi.interpolate`integrations/${integration.id}`,
})