A developer is configuring security for an Amazon API Gateway REST API. The API needs to validate JSON Web Tokens (JWT) issued by an Amazon Cognito User Pool. Additionally, the backend Lambda function, which is integrated using a Lambda Proxy integration, must be able to read the user's group memberships to apply application-level authorization. Which two configuration steps should the developer perform to achieve this? (Select TWO.)
- Create an Amazon Cognito User Pool authorizer in API Gateway, pointing to the user pool, and set the Identity Source to read the Authorization header.Answer
- Configure the API Gateway resource methods to use the Cognito User Pool authorizer, and extract the group memberships from the request context authorizer claims in the Lambda function.Answer
- CCreate an Amazon Cognito Identity Pool authorizer in API Gateway, and configure the clients to sign API requests using AWS Signature Version 4.
- DDeploy a custom Lambda authorizer that retrieves the JSON Web Key Set (JWKS) from Cognito to verify the JWT and inject the groups into custom headers for every request.
- EConfigure a Lambda Custom integration and define an API Gateway mapping template to extract the Cognito claims from the request headers and map them into the event object.
Answer
Create a Cognito User Pool authorizer configured to read the Authorization header, associate it with the API methods, and access the groups from the event request context authorizer claims in the Lambda function.
The correct options describe creating a Cognito User Pool authorizer and configuring it on the API methods, while retrieving the token claims directly from the request context authorizer claims. This provides a secure, native, and low-latency solution that leverages API Gateway's built-in validation capabilities. Under a Lambda Proxy integration, the validated token claims are automatically passed to the Lambda function's event payload.
Step-by-Step Solution
Key Concept
API Gateway Cognito User Pool Authorizers and requestContext claims propagation with Lambda Proxy integration.