A company is building an employee portal that allows users to access internal resources via an Amazon API Gateway REST API. The client application authenticates users directly using an Amazon Cognito User Pool. The developer needs to secure the API Gateway methods to ensure that only users authenticated by this Cognito User Pool can access the endpoints. The solution must minimize development effort and avoid unnecessary execution costs.
Which two of the following configuration steps must be performed in Amazon API Gateway to secure the API?
- Create a Cognito user pool authorizer in API Gateway by specifying the Amazon Cognito User Pool ARN and the token source header name.Answer
- BCreate a Cognito identity pool authorizer in API Gateway by specifying the Identity Pool ID and the token source header name.
- Edit the Method Request settings for the API methods, select the Cognito authorizer as the Authorization type, and redeploy the API.Answer
- DCreate a custom Lambda authorizer that extracts the JSON Web Token (JWT) from the headers, verifies it using public keys, and returns an IAM policy.
- EConfigure the integration request as a Lambda Proxy integration and implement code in the backend Lambda function to validate the JWT.
Answer
To secure the API natively using Cognito User Pools with the least overhead, the developer must create a Cognito user pool authorizer in API Gateway, link it to the Method Request settings for the API methods, and redeploy the API.
To secure the API with the minimum development and operational overhead, the developer should create a native Cognito User Pool authorizer by linking the Amazon Cognito User Pool ARN and the token source header name. The authorizer must then be assigned to the API's Method Request settings, followed by a redeployment of the API. This native validation does not require writing custom code and does not incur Lambda execution costs for the authorization layer.
Step-by-Step Solution
Key Concept
API Gateway integration with Amazon Cognito User Pools