This rule ensures enabling AWS X-Ray tracing for API Gateway REST API stages.
Rule | API Gateway REST API stages should have AWS X-Ray tracing enabled |
Framework | AWS Foundational Security Best Practices |
Severity | ✔ Low |
Rule Description:
API Gateway is a service provided by AWS that allows you to create, publish, and manage your own APIs. AWS X-Ray is a distributed tracing tool that helps you analyze and debug production applications, such as REST APIs, that are running in AWS. Enabling X-Ray tracing for API Gateway REST API stages ensures that you can accurately trace and track requests as they flow through your API, helping you identify and diagnose performance issues or potential security risks more effectively.
Troubleshooting Steps:
If X-Ray tracing is not enabled for your API Gateway REST API stages, you can follow these steps to troubleshoot and enable it:
Check API Gateway Stage Configuration: Ensure that you have the necessary permissions to modify API Gateway resources and check the stage configuration. Specifically, verify that the tracing setting for the stage is not set to "None" or "PassThrough."
Enable X-Ray Tracing: To enable X-Ray tracing for your API Gateway REST API stage, you can use the AWS Command Line Interface (CLI) or AWS Management Console.
CLI Command: Use the following AWS CLI command to enable X-Ray tracing for a specific stage:
aws apigateway update-stage --rest-api-id <REST_API_ID> --stage-name <STAGE_NAME> --patch-operations op=replace,path=/tracingEnabled,value=true
Replace
<REST_API_ID>
with the ID of your REST API and <STAGE_NAME>
with the name of your stage.AWS Management Console:
Verify X-Ray Integration: Once the X-Ray tracing is enabled, you can verify if it is functioning correctly by following these steps:
Necessary Codes:
No specific code is required to enable X-Ray tracing for API Gateway REST API stages. Instead, you can use the provided CLI command or AWS Management Console instructions as mentioned in the Troubleshooting Steps section.
Step-by-Step Guide for Remediation:
To enable AWS X-Ray tracing for your API Gateway REST API stages, follow these steps:
Check Stage Configuration:
Access Stage Settings:
Enable X-Ray Tracing:
Save Changes:
Verify X-Ray Integration:
By following these steps, you will ensure that X-Ray tracing is enabled and functioning for your API Gateway REST API stages, adhering to the AWS Foundational Security Best Practices.