turbot/steampipe-mod-terraform-aws-compliance

Control: EC2 AMI image builder image recipes should be encrypted with KMS CMK

Description

This control checks whether EC2 AMI image builder image recipes are encrypted with KMS CMK.

Usage

Run the control in your terminal:

powerpipe control run terraform_aws_compliance.control.ec2_ami_imagebuilder_image_recipe_encrypted_with_kms_cmk

Snapshot and share results via Turbot Pipes:

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

SQL

This control uses a named query:

select
address as resource,
case
when (attributes_std -> 'block_device_mapping' -> 'ebs' ->> 'kms_key_id') is null or (attributes_std -> 'block_device_mapping' -> 'ebs' ->> 'encrypted') <> 'true' or (attributes_std -> 'block_device_mapping' -> 'ebs' ->> 'encrypted') is null then 'alarm'
else 'ok'
end as status,
split_part(address, '.', 2) || case
when (attributes_std -> 'block_device_mapping' -> 'ebs' ->> 'kms_key_id') is null or (attributes_std -> 'block_device_mapping' -> 'ebs' ->> 'encrypted') <> 'true' or (attributes_std -> 'block_device_mapping' -> 'ebs' ->> 'encrypted') is null then ' is not encrypted with CMK'
else ' is encrypted with CMK'
end || '.' as reason
, path || ':' || start_line
from
terraform_resource
where
type = 'aws_imagebuilder_image_recipe';

Tags