| name | cis-aws-compute-2.12 |
| description | Ensure EBS volumes attached to an EC2 instance are marked for deletion upon instance termination |
| category | cis-compute |
| version | 1.1.0 |
| author | cyberstrike-official |
| tags | ["cis","aws","compute","ec2","ebs","delete-on-termination","lifecycle"] |
| cis_id | 2.12 |
| cis_benchmark | CIS AWS Compute Services Benchmark v1.1.0 |
| tech_stack | ["aws"] |
| cwe_ids | [] |
| chains_with | ["cis-aws-compute-2.2.4","cis-aws-compute-2.11"] |
| prerequisites | [] |
| severity_boost | {} |
Ensure EBS volumes attached to an EC2 instance are marked for deletion upon instance termination
Description
This rule ensures that Amazon Elastic Block Store volumes that are attached to Amazon Elastic Compute Cloud (Amazon EC2) instances are marked for deletion when an instance is terminated. If an Amazon EBS volume isn't deleted when the instance that it's attached to is terminated, it may violate the concept of least functionality.
Rationale
Orphaned EBS volumes after instance termination can contain sensitive data and increase costs. Marking volumes for deletion on termination ensures cleanup.
Impact
Data on the EBS volume will be permanently lost when the instance is terminated. Ensure important data is backed up before enabling this setting.
Audit Procedure
Using AWS CLI
- Run the describe-instances command:
aws ec2 describe-instances --region us-east-1 --output json --filters "Name=block-device-mapping.delete-on-termination,Values=false" --query "Reservations[*].Instances[*].{Instance:InstanceId}"
- The output should be a list of instances that have not set 'Delete on termination'.
- Make note of the list of instance ids and refer to the remediation below.
- Repeat steps no. 1 -3 with the other
AWS regions.
Using AWS Console
- Login to EC2 using https://console.aws.amazon.com/ec2/
- On the left Click
INSTANCES, click Instances.
- Select the
EC2 instance you want to review.
- Select the
Storage tab.
- Scroll down until you reach the 'Volume ID' and review the setting for 'Delete on termination'.
- If the value is set to
No refer to the remediation below.
- Repeat steps no. 3 - 6 to verify the setting.
- Go through the other
AWS regions and repeat the audit process for all instances.
Expected Result
The CLI command should return an empty list, indicating all EBS volumes attached to instances have DeleteOnTermination set to true.
Remediation
Using AWS CLI
- Run the modify-instance-attribute command using the list of instances collected in the audit:
aws ec2 modify-instance-attribute --instance-id i-123456abcdefghi0 --block-device-mappings