For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/cloudformation-aws-ebs-volume-not-attached-to-instances.md.
A documentation index is available at /llms.txt.
Unattached Amazon EBS volumes can retain sensitive data at rest and therefore increase the risk of data exposure or unauthorized access if snapshots are created, shared, or the storage is otherwise misused. In CloudFormation, each AWS::EC2::Volume should be associated with an AWS::EC2::VolumeAttachment whose Properties.VolumeId references the volume (typically using Ref to the volume logical ID). Resources missing a corresponding AWS::EC2::VolumeAttachment or where no AWS::EC2::VolumeAttachment resource’s Properties.VolumeId equals the volume’s Ref will be flagged.
Note: This rule detects explicit AWS::EC2::VolumeAttachment resources and may not catch attachments made via instance block device mappings, LaunchConfigurations, or Auto Scaling constructs.