Description
CloudTrail stores encrypted logs in S3. Use a customer managed key in kms_key_id if you need a separate key policy and an audit trail of key use.
Potential impact
Incorrect key permissions can interrupt delivery or block an auditor from reading logs.
Remediation
Choose a symmetric KMS key in the log bucket’s Region. Grant CloudTrail encryption and S3 write permissions. Grant approved readers S3 read and KMS decrypt permissions. Check a newly delivered log’s S3 properties for the intended KMS key, then open the file as an approved reader.
Examples
Use amazon.aws.cloudtrail in new playbooks and point the example alias at your key. The second task also enables multi-Region logging and log file validation, configures CloudWatch Logs and omits the S3 prefix. Keep your prefix when changing only the key. Supply the log group and role if using CloudWatch Logs.
Before
- name: Create CloudTrail
community.aws.cloudtrail:
state: present
name: default
s3_bucket_name: mylogbucket
s3_key_prefix: cloudtrail
region: us-east-1
After
- name: Create CloudTrail
community.aws.cloudtrail:
state: present
name: default
s3_bucket_name: mylogbucket
region: us-east-1
is_multi_region_trail: true
enable_log_file_validation: true
cloudwatch_logs_role_arn: arn:aws:iam::123456789012:role/CloudTrail_CloudWatchLogs_Role
cloudwatch_logs_log_group_arn: arn:aws:logs:us-east-1:123456789012:log-group:CloudTrail/DefaultLogGroup:*
kms_key_id: alias/MyAliasName