AWS CLI to list AWS VPCs in the account

Get the list of VPCs in the AWS account

Nov 13, 2022

Get the list of VPCs in the AWS account

Prerequisites

AWS CLI command to list VPCs

# filename: list-vpcs

aws ec2 describe-vpcs \
  --query 'Vpcs[*].{
    Id: VpcId,
    Default: IsDefault,
    Cidr: CidrBlock,
    Name:Tags[?Key==`Name`]|[0].Value
    }' \
  --output table

Sample output

----------------------------------------------------------------------
|                            DescribeVpcs                            |
+---------------+----------+-------------------------+---------------+
|     Cidr      | Default  |           Id            |     Name      |
+---------------+----------+-------------------------+---------------+
|  172.31.0.0/16|  True    |  vpc-ac2ec5d1           |  None         |
|  10.1.0.0/16  |  False   |  vpc-01e4c64e6e81c5d85  |  SampleCoVPC  |
+---------------+----------+-------------------------+---------------+

See also