A developer is designing a REST API using Amazon API Gateway that routes client requests to an AWS Lambda backend. The API must satisfy the following development requirements:
1. Authenticate and validate JSON Web Tokens (JWTs) issued by an Amazon Cognito User Pool at the gateway level before forwarding requests.
2. Pass the complete HTTPS request details (including path parameters, headers, and query strings) directly to the Lambda function without the developer having to configure or maintain mapping templates.
Which two actions should the developer take to meet these requirements?
- Configure a Cognito User Pool Authorizer on the API Gateway resource method.Cevap
- Use a Lambda Proxy Integration for the API Gateway integration type.Cevap
- CCreate a custom Lambda Authorizer to validate the JWT and generate an IAM policy dynamically.
- DUse a Lambda Custom Integration and configure request mapping templates to format the incoming payload for the Lambda function.
- EEnable CORS at the API Gateway resource level and rely on API Gateway to append the Access-Control-Allow-Origin header to the Lambda proxy responses.
Cevap
Configure a Cognito User Pool Authorizer on the API Gateway resource method, and use a Lambda Proxy Integration for the API Gateway integration type.
The correct options are configuring a Cognito User Pool Authorizer and using a Lambda Proxy Integration. A Cognito User Pool Authorizer natively validates JWT tokens at the gateway level without custom code. A Lambda Proxy Integration automatically passes the request context (headers, path parameters, query strings) directly to the Lambda function as a structured event payload, satisfying the requirement to avoid configuring mapping templates.
Adım Adım Çözüm
Anahtar Kavram
Configuring API Gateway integrations and authorizers to optimize development overhead and maintain native features.