turbot/terraform_aws_compliance

Query: ec2_instance_user_data_no_secrets

Usage

powerpipe query terraform_aws_compliance.query.ec2_instance_user_data_no_secrets

Steampipe Tables

SQL

select
address as resource,
case
when (attributes_std ->> 'user_data') is null then 'skip'
when (attributes_std ->> 'user_data') like any (array ['%pass%', '%secret%','%token%','%key%'])
or (attributes_std ->> 'user_data') ~ '(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]' then 'alarm'
else 'ok'
end as status,
split_part(address, '.', 2) || case
when (attributes_std ->> 'user_data') is null then ' no user data defined.'
when (attributes_std ->> 'user_data') like any (array ['%pass%', '%secret%','%token%','%key%'])
or (attributes_std ->> 'user_data') ~ '(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]' then ' potential secret found in user data.'
else ' no secrets found in user data.'
end as reason
, path || ':' || start_line
from
terraform_resource
where
type = 'aws_instance';

Controls

The query is being used by the following controls: