proud-dress-36576
07/05/2024, 2:23 PMimport { AuthorizerArgs } from "@pulumi/aws-apigateway/types/input";
import * as apigateway from "@pulumi/aws-apigateway";
// Define the common authorizer
const commonAuthorizer: AuthorizerArgs = {
parameterName: "Authorization",
parameterLocation: "header",
identityValidationExpression: "^Bearer [-0-9a-zA-Z._]*$",
authType: "custom",
type: "token",
identitySource: ["method.request.header.Authorization"],
handler: authorizerLambda,
authorizerResultTtlInSeconds: 600,
};
// Create the API Gateway with routes
const api = new apigateway.RestAPI("test-api", {
stageName: "v1",
routes: [
{
path: "/route1",
method: "PUT",
eventHandler: route1PutLambdaFunction,
authorizers: [commonAuthorizer],
},
{
path: "/route1",
method: "DELETE",
eventHandler: route1DeleteLambdaFunction,
authorizers: [commonAuthorizer],
},
{
path: "/route2",
method: "PUT",
eventHandler: route2PutLambdaFunction,
authorizers: [commonAuthorizer],
},
{
path: "/route3",
method: "PUT",
eventHandler: route3PutLambdaFunction,
authorizers: [commonAuthorizer],
},
// Add more routes as needed
],
});
Issue: Even though I define a single commonAuthorizer
, pulumi up
creates a separate authorizer for each route. If there are 10 routes, it generates 10 different authorizers, roles, and permissions. This duplication causes exceed the default api gateway authorizers limit of 10.
Expected Behavior: I want to reuse the same authorizer across all multiple routes.
Actual Behavior: Each route creates its own authorizer, resulting in unnecessary duplication and deployment hangs with more than 10 routes.
Question: How can I ensure a single custom authorizer is reused across all routes?
Adding the authorizerName
field into the authorizer is throwing unique name requiring error
attempting to create two authorizers with same name.
Issue is reported, follow it from the thread!proud-dress-36576
07/09/2024, 1:03 PMNo 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