For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/terraform-aws-api-gateway-access-logging-disabled.md.
A documentation index is available at /llms.txt.
When configuring an AWS API Gateway stage in Terraform, it is important to define the access_log_settings block to ensure that access logs are collected and sent to a centralized logging destination, such as an Amazon CloudWatch Logs group. Without specifying the access_log_settings, as shown in the configuration below, API requests and responses will not be logged, making it difficult to detect anomalous activity, debug issues, or perform security investigations:
The absence of access logging creates a blind spot in monitoring and incident response, potentially allowing malicious activities and API misuse to go unnoticed. To address this, always include the access_log_settings block in your API Gateway stage resource, specifying a valid destination_arn: