By using AWS re:Post, you agree to the Terms of Use

attach lambda authorizer to http API


Hi team,

I want to create an API gw lambda authorizer and attach it to the HTTP API

this is the piece of code I did :

// create api gw authorizer
    const apiGwAuthorizer = new HttpLambdaAuthorizer(
        responseTypes: [HttpLambdaResponseType.SIMPLE], 
        identitySource: ["$"],
        resultsCacheTtl: Duration.seconds(300),

    //attach the authorizer to the ANY route
      integration: new HttpLambdaIntegration(
      path: "/ANY /{proxy+}",
      authorizer: apiGwAuthorizer ,

but when I deploy the CDK this authorizer created but it's not associated with the API GW

the API GW is passed as parameter from other stack in this stack

Not sure what I miss here, is it because the route 'ANY /{proxy+}' already exists?

1 Answer

Not sure, but try doing it the other way around (if you want to split into two stacks). Create the Lambda function in one stack. In the API GW stack, attach the authorizer to the right routes.

profile picture
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions