A developer is configuring a REST API in Amazon API Gateway that integrates with an AWS Lambda function. The API must use a Lambda non-proxy (custom) integration to allow request transformation. The developer needs to pass the incoming client request header X-App-Tenant-Id as a JSON property named tenantId in the payload sent to Lambda. Additionally, if the Lambda function fails with an error message containing TenantSuspended, the API must return an HTTP 403 Forbidden status code and a custom JSON message to the client. Which two configurations are required to meet these requirements? (Select two.)
- Define a mapping template of type application/json in the Integration Request that extracts the header value using the expression $input.params('X-App-Tenant-Id').Cevap
- Configure an Integration Response with a Lambda Error Regex pattern set to .*TenantSuspended.* and map it to a Method Response with a 403 status code.Cevap
- CEnable Lambda Proxy Integration, then configure the Integration Response regex to intercept the Lambda execution error and map it to a 403 status code.
- DCreate a custom Lambda Authorizer to catch the backend Lambda execution exception and return an IAM policy denying access to the resource.
- EConfigure an API Gateway Response of type DEFAULT_5XX to intercept the Lambda error and map the response body to a 403 status code.
Cevap
To pass the header, define an Integration Request mapping template for application/json that extracts the header using $input.params('X-App-Tenant-Id'). To map the backend error, configure an Integration Response with a Lambda Error Regex pattern matching .*TenantSuspended.* and map it to a 403 Method Response.
The correct configurations are defining a mapping template in the Integration Request using the $input.params('X-App-Tenant-Id') expression, and configuring an Integration Response with a Lambda Error Regex pattern to capture the exception and return a 403 Method Response. With Lambda non-proxy integration, developers use Integration Request mapping templates to extract parameters and shape the payload, and Integration Responses to map backend error messages to target HTTP status codes.
Adım Adım Çözüm
Anahtar Kavram
API Gateway Lambda Custom Integration Request and Response Mapping
Tahmini Süre:2m 0s