Amazon Machine Images (AMIs) created without EBS encryption can result in sensitive data stored on volumes being exposed if the underlying storage is compromised. To mitigate this, AMI resources should have the encrypted = true attribute set within each ebs_block_device block to ensure all data at rest is protected.
For example, a secure Terraform configuration would look like the following:
#this code is a correct code for which the query should not find any result
resource"aws_ami""negative1"{name="terraform-example"virtualization_type="hvm"root_device_name="/dev/xvda2"ebs_block_device{device_name="/dev/xvda2"snapshot_id="snap-xxxxxxxx"volume_size=8encrypted=true}}