turbot/steampipe-mod-aws-compliance

Control: EC2 instances should use IMDSv2

Description

Ensure the Instance Metadata Service Version 2 (IMDSv2) method is enabled to help protect access and control of AWS Elastic Compute Cloud (AWS EC2) instance metadata.

Usage

Run the control in your terminal:

powerpipe control run aws_compliance.control.ec2_instance_uses_imdsv2

Snapshot and share results via Turbot Pipes:

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

SQL

This control uses a named query:

select
arn as resource,
case
when metadata_options ->> 'HttpTokens' = 'optional' then 'alarm'
else 'ok'
end as status,
case
when metadata_options ->> 'HttpTokens' = 'optional' then title || ' not configured to use Instance Metadata Service Version 2 (IMDSv2).'
else title || ' configured to use Instance Metadata Service Version 2 (IMDSv2).'
end as reason
, region, account_id
from
aws_ec2_instance;

Tags