A Default VPC is created in each region when an AWS account is created. The default VPC comes up with few already configured VPC elements. They're:
172.31.0.0/16
/16
means the first 16
bits of this range is fixed. It allows a maximum of 65536
IP addresses, starting with 172.31.0.0
and ending with 172.31.255.255
172.31.0.0/20
4096
IP addresses (first 20 bits fixed. This leaves 32 - 20 = 12 bits for the Subnet. 2 Power 12 is 4096)5
addresses for management.4091
addresses for the subnet.172.31.0.0
and last address is 172.31.15.255
172.31.16.0/20
4091
addresses (After leaving 5
for AWS)172.31.16.0
, last address is 172.31.31.255
172.31.32.0/20
4091
addresses (After leaving 5
for AWS)172.31.32.0
, last address is 172.31.47.255
0.0.0.0/0
), will be directed to the Internet Gateway that is already created and attached to the VPC.0.0.0.0/0
) on any Protocol/Port. Similarly, the default outbound rule allows traffic to leave the subnet on any Protocol/Port.# Print Default VPC ID (in the region configured when setting up CLI)
aws ec2 describe-vpcs --filters "Name=isDefault,Values=true" --query 'Vpcs[].VpcId' --output table
------------------
| DescribeVpcs |
+----------------+
| vpc-522b2535 |
+----------------+
VPC_ID=$(aws ec2 describe-vpcs --filters "Name=isDefault,Values=true" --query 'Vpcs[].VpcId' --output text) && echo ${VPC_ID}
echo $VPC_ID
vpc-522b2535
# Describe Subnets
aws ec2 describe-subnets \
--filters "Name=vpc-id,Values=${VPC_ID}" \
--query 'Subnets[].[SubnetId,CidrBlock,AvailabilityZone, Tags[?Key==`Name`]|[0].Value]' \
--output table
+-----------------+------------------+-------------------+-------+
| subnet-f82987a1| 172.31.0.0/20 | ap-southeast-1c | None |
| subnet-2234d76a| 172.31.32.0/20 | ap-southeast-1a | None |
| subnet-2c45b64a| 172.31.16.0/20 | ap-southeast-1b | None |
+-----------------+------------------+-------------------+-------+
# Security Groups
aws ec2 describe-security-groups \
--filters "Name=vpc-id,Values=${VPC_ID}" \
--query 'SecurityGroups[].[GroupId, Description]' \
--output table
-----------------------------------------------
| DescribeSecurityGroups |
+--------------+------------------------------+
| sg-4b59a835 | default VPC security group |
+--------------+------------------------------+
aws ec2 describe-route-tables \
--filters "Name=vpc-id,Values=${VPC_ID}" \
--filters "Name=association.main,Values=true" \
--query 'RouteTables[].Associations[].{RouteTableId:RouteTableId}' \
--output table