API Gateway X-Ray tracing disabled

Disabled X-Ray tracing on a REST API can make request-path and latency analysis harder.

Description

Enable X-Ray on a REST API stage to follow sampled requests across services.

Potential impact

A trace can show which service delayed or failed a request. Use access logs when you need a record of each request.

Remediation

Set xray_tracing_enabled = true on aws_api_gateway_stage. Check X-Ray permissions and sampling, then confirm that a trace from the deployed stage reaches the backends you instrumented.

Examples

The prod stage refers to an existing REST API and deployment. Use your Terraform resource references.

Before

hcl
resource "aws_api_gateway_stage" "example" {
  stage_name           = "prod"
  rest_api_id          = aws_api_gateway_rest_api.test.id
  deployment_id        = aws_api_gateway_deployment.test.id
  xray_tracing_enabled = false
}

After

hcl
resource "aws_api_gateway_stage" "example" {
  stage_name           = "prod"
  rest_api_id          = aws_api_gateway_rest_api.test.id
  deployment_id        = aws_api_gateway_deployment.test.id
  xray_tracing_enabled = true
}

References