turbot/steampipe-mod-aws-compliance

Control: EC2 instances should not use key pairs in running state

Description

This control checks whether running EC2 instances are using key pairs. The control fails if a running EC2 instance uses a key pair.

Usage

Run the control in your terminal:

powerpipe control run aws_compliance.control.ec2_instance_no_amazon_key_pair

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run aws_compliance.control.ec2_instance_no_amazon_key_pair --share

SQL

This control uses a named query:

select
arn as resource,
case
when instance_state <> 'running' then 'skip'
when key_name is null then 'ok'
else 'alarm'
end as status,
case
when instance_state <> 'running' then title || ' is in ' || instance_state || ' state.'
when key_name is null then title || ' not launched using amazon key pairs.'
else title || ' launched using amazon key pairs.'
end as reason
, region, account_id
from
aws_ec2_instance;

Tags