Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path parameters, body coming as null while using authorizer in aws lambda

I have create a Lambda authorizor method (token based), with custom vpc and integrated with another lambda for api gateway authorization, when the authorization succeeds and when it wents to the destination lambda the path parameters and query parameters in event are coming as null.

in serverless.yml file authorizor function

authorizer:
  handler: authorizerHandler.verifyUser
  vpc: ${customvpc}

in serverless.yml file normal lambda

 user:
  handler: user.router
  vpc: ${customvpc}
  integration:lambda
  events:
     - http:
         path:api/v1/user/{id}
         cors: true

when user authorized, i am passing returning the object as

{
  "principalId": "yyyyyyyy", // The principal user identification associated with the token sent by the client.
  "policyDocument": {
    "Version": "2012-10-17",
    "Statement": [
      {
        "Action": "execute-api:Invoke",
        "Effect": "Allow|Deny",
        "Resource": "arn:aws:execute-api:{regionId}:{accountId}:{apiId}/{stage}/{httpVerb}/[{resource}/[{child-resources}]]"
      }
    ]
  }
}

but when i tried to use the id in event.pathParameter it is returning null, the same goes with queryStringParameters. any one can help?

thanks in advance :-)

like image 598
Novudu Soma Sekhar Avatar asked Oct 22 '25 03:10

Novudu Soma Sekhar


1 Answers

I think you need to use curly braces {id} instead of colons :id

 user:
  handler: user.router
  vpc: ${customvpc}
  integration:lambda
  events:
     - http:
         path:api/v1/user/{id}
         cors: true
like image 196
Aaron Stuyvenberg Avatar answered Oct 23 '25 18:10

Aaron Stuyvenberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!