turbot/terraform_aws_compliance

Query: ec2_instance_not_use_default_vpc

Usage

powerpipe query terraform_aws_compliance.query.ec2_instance_not_use_default_vpc

Steampipe Tables

SQL

select
address as resource,
case
when (attributes_std -> 'subnet_id') is null then 'skip'
when split_part((attributes_std ->> 'subnet_id'), '.', 2) in (select name from terraform_resource where type = 'aws_subnet' and (attributes_std ->> 'vpc_id') like '%default%') then 'alarm'
else 'ok'
end as status,
split_part(address, '.', 2) || case
when (attributes_std -> 'subnet_id') is null then ' does not have a subnet id defined'
when split_part((attributes_std ->> 'subnet_id'), '.', 2) in (select name from terraform_resource where type = 'aws_subnet' and (attributes_std ->> 'vpc_id') like '%default%') then ' deployed to a default VPC'
else ' not deployed to a default VPC'
end || '.' as reason
, path || ':' || start_line
from
terraform_resource
where
type = 'aws_instance';

Controls

The query is being used by the following controls: