VTL - Authorized user

Limits the returned data to the authorized user

The snippet looks up the authorized user in the context.claims data from API Gateway. The returned user must match the owner which is the Global Secondary Index (GSI)

Limit returned data to authorized user

#set( $pageKey = $input.params('pageKey'))
{
  "TableName": "myTable",
  "IndexName":"OwnerIndex",
  "KeyConditionExpression": "#n_owner = :v_owner",
  "ExpressionAttributeValues": {
    ":v_owner": {"S": "$context.authorizer.claims.email"}
  },
  "ExpressionAttributeNames": {"#n_owner": "owner"}
}
                                


Created by:

Eric Johnson

Eric Johnson

Eric Johnson is a Principal Developer Advocate for Serverless Applications at Amazon Web Services and is based in Northern Colorado. Eric is a fanatic about serverless and enjoys helping developers understand how serverless technologies introduces a major paradigm shift in how they approach building and running applications at massive scale with minimal administration overhead. Prior to this, Eric has worked as a developer, solutions architect and AWS Evangelist for an AWS partner company.

Follow on LinkedIn