chilly-glass-80061
07/22/2024, 1:36 AM// Return aws.lambda.Function
const testingHandler = createLambda(
"testingHandler",
config,
{
handler: "testingHandler.handler",
},
);
const openApiSpec = {
openapi: "3.0.1",
info: {
title: "Lambda API testing",
version: "1.0.0",
},
paths: {
"/hello": {
get: {
"x-amazon-apigateway-integration": {
type: "aws_proxy",
httpMethod: "POST",
uri: pulumi.interpolate`arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/${testingHandler.invokeArn}/invocations`,
connectionType: "INTERNET",
},
responses: {
"200": {
description: "A simple hello world response",
},
},
},
},
},
};
// API Gateway Rest API
const api = new aws.apigatewayv2.Api("apiTesting", {
protocolType: "HTTP",
body: JSON.stringify(openApiSpec),
});
// Create a stage for the API
new aws.apigatewayv2.Stage("stageTesting", {
apiId: api.id,
name: "v1",
autoDeploy: true,
});
But when I go to the API gateway in AWS console, the stage was not able to deploy Unable to deploy API because no routes exist in this API
When I do export my OpenAPI spec from the API gateway, somehow the x-amazon-apigateway-integration got removed
Does anyone have any idea what I could be missing?modern-zebra-45309
07/22/2024, 9:40 AMJSON.stringify
when there is a Pulumi output in the JSON, because the output's value is not yet known at the point in time the code is executed.
Pulumi provides a utility function pulumi.jsonStringify
for that purpose, see https://www.pulumi.com/docs/concepts/inputs-outputs/apply/#converting-json-objects-to-strings
If you replace JSON.stringify
with pulumi.jsonStringify
you'll pass the proper API spec to the API gateway resource. To inspect your generated API spec, you can export it as a stack output.No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by