A developer is configuring a REST API in Amazon API Gateway using an HTTP custom (non-proxy) integration to connect to a legacy backend HTTP service. The API must map the backend service's Service Unavailable response to a Gateway Timeout client response. Additionally, the backend service requires the client's IP address to be sent in a custom header named `X-Forwarded-For-IP` derived from the API Gateway context. Which TWO configuration steps must the developer perform in API Gateway to meet these requirements?
- In the Integration Request settings, add a header parameter mapping for `X-Forwarded-For-IP` with a source of `context.identity.sourceIp`.Cevap
- In the Method Response settings, define a HTTP status code, and in the Integration Response settings, create a mapping with an HTTP status regex of mapping to the method response status.Cevap
- CEnable HTTP Proxy integration and use an API Gateway request mapping template to map the `X-Forwarded-For-IP` header from `$context.identity.sourceIp`.
- DIn the Integration Response settings, map the HTTP status regex of to the method response status, and define the status code directly in the Integration Request settings.
- EConfigure a custom Lambda authorizer to inject the `X-Forwarded-For-IP` header into the integration request and intercept the backend response to modify the status code.
Cevap
In the Integration Request settings, add a header parameter mapping for `X-Forwarded-For-IP` with a source of `context.identity.sourceIp`. In the Method Response settings, define a HTTP status code, and in the Integration Response settings, create a mapping with an HTTP status regex of mapping to the method response status.
To forward the client's IP, the developer must use the Integration Request settings to map `X-Forwarded-For-IP` to the context variable `context.identity.sourceIp`. To map the status code, the developer must declare the response in the Method Response, and then create an Integration Response mapping with a regex of to translate the backend error code to the client response code.
Adım Adım Çözüm
Anahtar Kavram
API Gateway Custom HTTP Integration parameter and status mapping
Tahmini Süre:2m 30s