Every server in Chapter 4 ran inside a network you never saw: the region's default VPC. A VPC (Virtual Private Cloud) is a private network of your own, in one region. You decide its addresses and how it connects to the internet.
A VPC's addresses are written as a CIDR block:
10.0.0.0the first address/16how many bits are fixed
| Block | Fixed part | Addresses |
|---|---|---|
10.0.0.0/16 | 10.0 | 65,536 (10.0.0.0 to 10.0.255.255) |
10.0.1.0/24 | 10.0.1 | 256 (10.0.1.0 to 10.0.1.255) |
A bigger number after the / means a smaller range. A VPC usually takes a /16.
New command
aws ec2 create-vpc
Makes a VPC with that address range. Its answer holds the new VPC's id, VpcId.
Usageaws ec2 create-vpc --cidr-block block --tag-specifications 'ResourceType=vpc,Tags=[{Key=Name,Value=name}]'
Example
aws ec2 create-vpc --cidr-block 10.20.0.0/16 --tag-specifications 'ResourceType=vpc,Tags=[{Key=Name,Value=test-vpc}]'