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 réponses
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
répondu il y a un an
  • 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.

répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions