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}}
# A dynamic ebs_block_device block, generated via a real `terraform plan` /
# `terraform show -json`, fully resolves into planned_values.values as a
# normal array (with encrypted readable), same as a static block - the
# existing "Plan JSON variant" array-handling DatadogPolicy body already
# catches it. See test/positive2.json.
variable"devices"{type= list(object({device_name=string,encrypted=bool}))default=[{device_name="/dev/sdb",encrypted=false}]}resource"aws_ami""dynamic_block"{name="terraform-example-dynamic"virtualization_type="hvm"root_device_name="/dev/xvda2"dynamic"ebs_block_device"{for_each=var.devicescontent{device_name=ebs_block_device.value.device_nameencrypted=ebs_block_device.value.encrypted}}}
1
2
rulesets:- Terraform / AWS # Rules to enforce / AWS.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.