Description
CloudWatch Logs encrypts stored events by default. Associate a customer managed KMS key with a log group when your organization needs to control key policy or lifecycle.
Potential impact
Disabling a key or removing its permissions can make logs encrypted with that key unreadable.
Remediation
Set kms_key_id to the ARN of a symmetric key in the same Region and allow CloudWatch Logs to use it. The key applies to newly ingested events, so retain keys and permissions needed for older logs. Limit who can read logs, set retention and keep secrets out of log messages.
Examples
Default encryption at rest
resource "aws_cloudwatch_log_group" "example" {
name = "Yada"
tags = {
Environment = "production"
Application = "serviceA"
}
retention_in_days = 1
}
Both excerpts request one-day retention for the Yada log group. Replace the second excerpt’s ARN with the actual key and check the group’s KMS key association after deployment.
Specify a customer-managed key
resource "aws_cloudwatch_log_group" "example" {
name = "Yada"
tags = {
Environment = "production"
Application = "serviceA"
}
retention_in_days = 1
kms_key_id = "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
}