turbot/steampipe-mod-terraform-aws-compliance

Control: EC2 instances termination protection should be enabled

Description

To prevent your instance from being accidentally terminated using Amazon EC2, you can enable termination protection for the instance.

Usage

Run the control in your terminal:

powerpipe control run terraform_aws_compliance.control.ec2_instance_termination_protection_enabled

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run terraform_aws_compliance.control.ec2_instance_termination_protection_enabled --share

SQL

This control uses a named query:

select
address as resource,
case
when (attributes_std -> 'root_block_device' ->> 'delete_on_termination')::bool is true then 'ok'
else 'alarm'
end as status,
split_part(address, '.', 2) || case
when (attributes_std -> 'root_block_device' ->> 'delete_on_termination')::bool is true then ' instance termination protection enabled'
else ' instance termination protection disabled'
end || '.' as reason
, path || ':' || start_line
from
terraform_resource
where
type = 'aws_instance';

Tags