turbot/steampipe-mod-terraform-aws-compliance

Control: EC2 AMI launch permission should be restricted

Description

This control checks whether EC2 AMI launch permission is restrictive in nature.

Usage

Run the control in your terminal:

powerpipe control run terraform_aws_compliance.control.ec2_ami_launch_permission_restricted

Snapshot and share results via Turbot Pipes:

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

SQL

This control uses a named query:

select
address as resource,
case
when (attributes_std -> 'account_id') is not null then 'ok'
when (attributes_std -> 'group') is not null then 'info'
when (attributes_std -> 'organizational_arn') is not null then 'info'
when (attributes_std -> 'organizational_unit_arn') is not null then 'info'
else 'alarm'
end as status,
split_part(address, '.', 2) || case
when (attributes_std -> 'account_id') is not null then ' is restrictive to account(s)'
when (attributes_std -> 'group') is not null then ' is open to IAM group'
when (attributes_std -> 'organizational_arn') is not null then ' is open to organization'
when (attributes_std -> 'organizational_unit_arn') is not null then ' is open to organization unit'
else ' is wide open'
end || '.' as reason
, path || ':' || start_line
from
terraform_resource
where
type = 'aws_ami_launch_permission';

Tags