Sometimes we need to check the VPCs and Subnets in your AWS account. Especially, when we are experimenting a lot and we need to free up the VPCs to stay within the limits imposed by Amazon. We can quickly list all the VPCs and Subnets in your AWS account using the AWS CLI.
The describe-vpcs operation is used to retrieve details about your VPCs. The --query option is used to filter and format the output to show only the VPC IDs and their associated CIDR blocks. The --output table option formats the output as a table.
To list all subnets within a specific VPC or your current AWS region:
The AWS CLI commands default to the AWS region specified in your configuration. To list resources in a different region, add the --region parameter followed by the region code to your command (e.g., --region us-west-2).