Passing data from lambda to request header

0

My output from my authorizer follows the format specified by AWS, as seen below.

{
  "principalId": "yyyyyyyy",
  "policyDocument": {
    "Version": "2012-10-17",
    "Statement": [
      {
        "Action": "execute-api:Invoke",
        "Effect": "Allow|Deny",
        "Resource": "arn:aws:execute-api:<regionId>:<accountId>:<appId>/<stage>/<httpVerb>/[<resource>/<httpVerb>/[...]]"
      }
    ]
  },
  "context": {
    "company_id": "123",
    ...
  }
}

In my case, context contains a few parameters, like company_id, that I would like to pass along to my Node endpoint.

If I was to use a Lambda endpoint, I understand that this is done with Mapping Template and something like this:

{
  "company_id": "$context.authorizer.company_id"
}

However, Body Mapping Template is only available under Integration Request if Lambda is selected as Integration type. Not if HTTP is selected.

In short, how do I pass company_id from my Lambda authorizer to request header so that I can access the information in django?

I added the following under

Integration Request

  • And under Integration Request / HTTP Headers:

  • Name: company_id

  • Mapped from: context.authorizer.company_id

  • Cashing: optional

Still not able to get company_id under header in django request

  • Able to pull this off, missed adding the authorizer in MethodRequest. After adding authorizer in MethodRequest was able to get desired result

2개 답변
0

It seems you are following this stack overflow question: https://stackoverflow.com/questions/45631758/how-to-pass-api-gateway-authorizer-context-to-a-http-integration

From the answer there did you also add the company_id header in the Method Request / HTTP Request Headers section?

profile picture
답변함 일 년 전
  • Yes, I am following the stack overflow question. Have gone through further comments and documentation adding header in MethodRequest is not needed

0

Mapping templates are available with HTTP integration unless you also select HTTP Proxy. VTL is not super easy but you can start with the Method Request passthrough model and add the values you need.

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠