Table: aws_ec2_vpcs

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

https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Vpc.html (opens in a new tab)

The primary key for this table is arn.

Columns

NameType
_cq_iduuid
_cq_parent_iduuid
account_idutf8
regionutf8
arn (PK)utf8
tagsjson
cidr_blockutf8
cidr_block_association_setjson
dhcp_options_idutf8
instance_tenancyutf8
ipv6_cidr_block_association_setjson
is_defaultbool
owner_idutf8
stateutf8
vpc_idutf8

Example Queries

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

VPC flow logging should be enabled in all VPCs

SELECT
  'VPC flow logging should be enabled in all VPCs' AS title,
  aws_ec2_vpcs.account_id,
  aws_ec2_vpcs.arn,
  CASE
  WHEN aws_ec2_flow_logs.resource_id IS NULL THEN 'fail'
  ELSE 'pass'
  END
FROM
  aws_ec2_vpcs
  LEFT JOIN aws_ec2_flow_logs ON
      aws_ec2_vpcs.vpc_id = aws_ec2_flow_logs.resource_id;

Amazon EC2 should be configured to use VPC endpoints that are created for the Amazon EC2 service

WITH
  endpoints
    AS (
      SELECT
        vpc_endpoint_id
      FROM
        aws_ec2_vpc_endpoints
      WHERE
        vpc_endpoint_type = 'Interface'
        AND service_name ~ concat('com.amazonaws.', region, '.ec2')
    )
SELECT
  'Amazon EC2 should be configured to use VPC endpoints that are created for the Amazon EC2 service'
    AS title,
  account_id,
  vpc_id AS resource_id,
  CASE
  WHEN endpoints.vpc_endpoint_id IS NULL THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  aws_ec2_vpcs
  LEFT JOIN endpoints ON aws_ec2_vpcs.vpc_id = endpoints.vpc_endpoint_id;