APIs must send request logs and execution traces to CloudWatch Logs so activity, errors, and suspicious behavior can be detected and investigated. Without a configured log group, you lose critical visibility for incident response and troubleshooting.
In Ansible, tasks using the amazon.aws.cloudwatchlogs_log_group or cloudwatchlogs_log_group modules must include the log_group_name property to create or reference a specific CloudWatch Logs group. Tasks missing log_group_name (or with it unset) are flagged. Set log_group_name to a stable, descriptive string and ensure API Gateway access logging or tracing is pointed to that group.
Secure configuration example:
- name:Create CloudWatch log group for API Gatewayamazon.aws.cloudwatchlogs_log_group:log_group_name:"/aws/apigateway/my-api"state:presentretention_in_days:30
Compliant Code Examples
- name:Setup AWS API Gateway setup on AWS cloudwatchlogsamazon.aws.cloudwatchlogs_log_group:state:presentlog_group_name:test-log-grouptags:{Name: test-log-group, Env:QA}kms_key_id:arn:aws:kms:region:account-id:key/key-id
Non-Compliant Code Examples
---- name:Setup AWS API Gateway setup on AWS cloudwatchlogsamazon.aws.cloudwatchlogs_log_group:state:presentkms_key_id:arn:aws:kms:region:account-id:key/key-id
1
2
rulesets:- Ansible / AWS # Rules to enforce / AWS.
パーソナライズされたデモをリクエスト
Datadog を始める
Ask AI
AI-generated responses may be inaccurate. Verify important info.