Table: aws_ec2_subnets

This table shows data for Amazon Elastic Compute Cloud (EC2) Subnets.

https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Subnet.html (opens in a new tab) The 'request_account_id' and 'request_region' columns are added to show from where the request was made.

The composite primary key for this table is (request_account_id, request_region, arn).

Columns

NameType
_cq_iduuid
_cq_parent_iduuid
request_account_id (PK)utf8
request_region (PK)utf8
arn (PK)utf8
tagsjson
assign_ipv6_address_on_creationbool
availability_zoneutf8
availability_zone_idutf8
available_ip_address_countint64
cidr_blockutf8
customer_owned_ipv4_poolutf8
default_for_azbool
enable_dns64bool
enable_lni_at_device_indexint64
ipv6_cidr_block_association_setjson
ipv6_nativebool
map_customer_owned_ip_on_launchbool
map_public_ip_on_launchbool
outpost_arnutf8
owner_idutf8
private_dns_name_options_on_launchjson
stateutf8
subnet_arnutf8
subnet_idutf8
vpc_idutf8

Example Queries

These SQL queries are sampled from CloudQuery policies and are compatible with PostgreSQL.

EC2 subnets should not automatically assign public IP addresses

SELECT
  'EC2 subnets should not automatically assign public IP addresses' AS title,
  owner_id AS account_id,
  arn AS resource_id,
  CASE
  WHEN map_public_ip_on_launch IS true THEN 'fail'
  ELSE 'pass'
  END
FROM
  aws_ec2_subnets;

EMR clusters should not have public IP addresses

SELECT
  'EMR clusters should not have public IP addresses' AS title,
  aws_emr_clusters.account_id,
  aws_emr_clusters.arn AS resource_id,
  CASE
  WHEN aws_ec2_subnets.map_public_ip_on_launch
  AND aws_emr_clusters.status->>'State' IN ('RUNNING', 'WAITING')
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  aws_emr_clusters
  LEFT JOIN aws_ec2_subnets ON
      aws_emr_clusters.ec2_instance_attributes->>'Ec2SubnetId'
      = aws_ec2_subnets.subnet_id;