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-deployment-without-access-log-setting.md.
A documentation index is available at /llms.txt.
API Gateway deployments should have access_log_settings defined for each connected API Gateway Stage to ensure proper logging of API requests and responses. Without these settings, as shown below, critical API activity may go unlogged, making it difficult to track access patterns, detect malicious requests, or troubleshoot operational issues:
Leaving this misconfiguration unaddressed can hinder security monitoring and auditing, potentially exposing the environment to undetected abuse or data exfiltration.
Compliant Code Examples
resource"aws_api_gateway_deployment""example5"{rest_api_id="some rest api id"stage_name="some name"stage_description="some description"tags{project="ProjectName"}}resource"aws_api_gateway_stage""example0"{deployment_id=aws_api_gateway_deployment.example5.idrest_api_id=aws_api_gateway_rest_api.example.idstage_name="example"access_log_settings{destination_arn="dest"format="format"}}
Non-Compliant Code Examples
resource"aws_api_gateway_deployment""examplee"{rest_api_id="some rest api id"stage_name="some name"tags{project="ProjectName"}}resource"aws_api_gateway_stage""example00"{deployment_id=aws_api_gateway_deployment.example.idrest_api_id=aws_api_gateway_rest_api.example.idstage_name="example"}
resource"aws_api_gateway_deployment""example3"{rest_api_id="some rest api id"stage_name="some name"tags{project="ProjectName"}}resource"aws_api_gateway_stage""example000"{deployment_id=aws_api_gateway_deployment.example3.idrest_api_id=aws_api_gateway_rest_api.example.idstage_name="example"}
resource"aws_api_gateway_deployment""example4"{rest_api_id="some rest api id"stage_name="some name"tags{project="ProjectName"}}resource"aws_api_gateway_stage""example0000"{deployment_id=aws_api_gateway_deployment.example4.idrest_api_id=aws_api_gateway_rest_api.example.idstage_name="example"access_log_settings{destination_arn="dest"format="format"}}
1
2
rulesets:- Terraform / AWS # Rules to enforce / AWS.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.