turbot/aws_compliance

Query: ec2_instance_attached_ebs_volume_delete_on_termination_enabled

Usage

powerpipe query aws_compliance.query.ec2_instance_attached_ebs_volume_delete_on_termination_enabled

Steampipe Tables

SQL

with ebs_volume_with_delete_on_termination_enabled as (
select
count(*) as count,
arn
from
aws_ec2_instance,
jsonb_array_elements(block_device_mappings) as p
where
p -> 'Ebs' ->> 'DeleteOnTermination' = 'false'
group by
arn
)
select
i.arn as resource,
case
when e.count > 0 then 'alarm'
else 'ok'
end as status,
case
when e.count > 0 then ' EBS volume(s) attached to ' || title || ' has delete on termination disabled.'
else ' EBS volume(s) attached to ' || title || ' has delete on termination enabled.'
end as reason
, region, account_id
from
aws_ec2_instance as i
left join ebs_volume_with_delete_on_termination_enabled as e on e.arn = i.arn;

Controls

The query is being used by the following controls: