More Info:
Cloudwatch loggroups should be encryptedRisk Level
HighAddress
SecurityCompliance Standards
HIPAA,PCIDSS,GDPR,CISAWS,CBP,NIST,SOC2,AWSWAF,SEBI,RBI_UCBTriage and Remediation
- Remediation
Remediation
Using Console
Using Console
Below are the exact console steps to ensure a CloudWatch Log Group is encrypted with a customer-managed KMS key (CMK).
Prerequisites: Create or identify a CMK
- Sign in to the AWS Management Console.
- Go to Key Management Service (KMS):
- In the search bar, type KMS, choose Key Management Service.
- Create a new CMK (if you don’t already have one for logs):
- In the left pane, choose Customer managed keys.
- Click Create key.
- Key type: Symmetric.
- Key usage: Encrypt and decrypt.
- Click Next and:
- Set an alias (e.g.,
alias/cloudwatch-logs-key). - Choose key administrators and key users (IAM roles/users that need to write/read logs).
- Set an alias (e.g.,
- Complete the steps and click Finish.
Note: Ensure the IAM roles/services that write to CloudWatch Logs (e.g., Lambda, ECS, EC2, etc.) are added as Key users so they can use the CMK.
Step-by-step: Encrypt an existing CloudWatch Log Group with CMK
- In the AWS console, go to CloudWatch.
- In the left navigation pane, select Log groups.
- Find and click the log group you want to encrypt.
- At the top right, choose Actions → Edit (or Edit encryption depending on UI).
- Under Encryption:
- Check/enable Encrypt log group (if shown).
- For KMS key, choose:
- Select KMS key and pick your customer-managed key (e.g.,
alias/cloudwatch-logs-key), notaws/logs(the AWS-managed key).
- Select KMS key and pick your customer-managed key (e.g.,
- Click Save changes.
Step-by-step: Set CMK encryption by default for new log groups (optional)
There is no global “default CMK for all log groups” setting in the console, but you can:-
Create log groups manually (instead of auto-created), and during creation:
- In CloudWatch → Log groups → Create log group.
- Enter Log group name.
- Under Encryption, choose your CMK.
- Click Create.
-
Or enforce via automation (CloudFormation, Terraform, or a Lambda that:
- Monitors for new log groups.
- Calls
AssociateKmsKeyto attach your CMK to them.)
Validate encryption
- In CloudWatch → Log groups, click the log group.
- Check the Encryption section:
- It should show KMS with your CMK alias/ARN.
- Optionally, in KMS → Customer managed keys, select your key and:
- Check Key usage and CloudTrail logs to confirm encryption operations.
Using CLI
Using CLI
Below are AWS CLI steps to ensure CloudWatch Log Groups are encrypted with a customer-managed KMS CMK.
Note the You can then use either the
Filter those without a This will output the names of log groups that are not using CMK encryption.
Or directly with the KeyId/KeyArn:
Update policy via:
You should see
1. (Optional) Create a KMS CMK for CloudWatch Logs
If you don’t already have a CMK you want to use:KeyId from the output. You can also create an alias:KeyId or the alias ARN as the --kms-key-id.2. Identify Log Groups Without CMK Encryption
List all log groups:kmsKeyId using jq (recommended):3. Associate a CMK with a Single Log Group
Useassociate-kms-key to enable CMK encryption:4. Apply CMK Encryption to All Unencrypted Log Groups (Batch)
Example Bash loop for all unencrypted log groups:5. (Important) KMS Key Policy Permissions
Ensure the CMK key policy allows CloudWatch Logs and any writers/readers to use it. Minimal example snippet in the KMS key policy:6. Verify Encryption
Check a specific log group:kmsKeyId populated with the CMK ARN.Using Python
Using Python
Below is a concise, step‑by‑step way to remediate “CloudWatch Log Groups should be encrypted with CMK” using Python (boto3).
Call this once to create the key:
Summary of flow:
1. Prerequisites
- Python 3.x
boto3installed:- AWS credentials configured (via
~/.aws/credentials, environment variables, or instance profile). - Permissions:
logs:DescribeLogGroups,logs:AssociateKmsKeykms:CreateKey,kms:DescribeKey,kms:ListAliases(if creating/using CMK)
2. Option A – Use an Existing KMS CMK
If you already have a KMS CMK (recommended), you just need its ARN or alias.2.1. Find CMK by alias (optional helper)
3. Option B – Create a New CMK for CloudWatch Logs
4. Associate CMK with All (or Selected) Log Groups
This script:- Lists all CloudWatch log groups.
- Identifies those without a
kmsKeyId(i.e., not using CMK). - Associates them with the specified CMK.
5. Verify Encryption
Programmatically:Summary of flow:
- Create or choose a KMS CMK (steps 2–3).
- Run the association script (step 4).
- Verify all log groups show
kmsKeyIdset (step 5).
Using Terraform
Using Terraform
- Replace
var.AWS_REGIONwith your region variable or hard-code the region string as needed. - If the log group already exists and is imported into Terraform, adding
kms_key_idis an in-place update and does not force replacement.
terraform plan should show an in-place update on aws_cloudwatch_log_group.this with kms_key_id changing from null to the CMK ARN, and creation of aws_kms_key.cloudwatch_logs.
