Skip to content

Retrieving users from custom authorizersΒΆ

We can modify the API's POS mapping template to retrieve the user from custom authorizer.

#set($inputRoot = $input.path('$'))
{
    "age" : "$inputRoot.age",
    "height" : "$inputRoot.height",
    "income" : "$inputRoot.income",
    "userId" : "$context.authorizer.principalId",
}

Then we can go back to the POST lambda file and change the hardcoded user id from:

S: "user_" + Math.random()

to:

S: event.userId