Description
After creating a log group with Ansible, configure the API Gateway stage to send access logs there. Access logs can record the request ID and response status. For processing errors, enable execution logs separately on a supported API type.
Potential impact
Without request records, it is harder to trace authentication failures or piece together unusual calls.
Remediation
Set the stage’s access log destination ARN and format, and grant API Gateway log delivery permissions. Set retention and read access, then look up a test request by ID. Keep tokens, passwords, and sensitive request bodies out of logs.
Examples
These tasks manage only the log group. Replace kms_key_id with your KMS key ARN and grant CloudWatch Logs permission to use the key.
Before
- name: Setup CloudWatch log group
community.aws.cloudwatchlogs_log_group:
state: present
kms_key_id: arn:aws:kms:region:account-id:key/key-id
The task is missing the required log_group_name and cannot create the group.
After
- name: Setup CloudWatch log group
community.aws.cloudwatchlogs_log_group:
state: present
log_group_name: test-log-group
kms_key_id: arn:aws:kms:region:account-id:key/key-id
log_group_name names the group test-log-group. Configure stage delivery separately.