A new VPC needs a block and, so you can find it again, a Name tag.
Creating it
VPC=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16 --tag-specifications 'ResourceType=vpc,Tags=[{Key=Name,Value=market}]' --query Vpc.VpcId --output text)--tag-specifications works as it did for instances in Chapter 3, with ResourceType=vpc. A create command answers with the thing it made, so --query Vpc.VpcId --output text prints just the new id, and VPC=$(…) keeps it. Every command in this chapter uses $VPC.
A larger block than /16 (a smaller number after the slash, such as /8) fails with InvalidVpc.Range.
What comes with it
No subnets yet, and no way in or out: a VPC starts sealed. The next lessons add the pieces.
DNS hostnames
aws ec2 modify-vpc-attribute --vpc-id $VPC --enable-dns-hostnamesThis gives instances with a public IP a public name as well, such as ec2-54-23-117-9.compute-1.amazonaws.com. The default VPC has it on; a new VPC does not.
Finding it again
A variable lasts only as long as the shell. In a new terminal, find the VPC by its Name tag:
VPC=$(aws ec2 describe-vpcs --filters Name=tag:Name,Values=market --query "Vpcs[0].VpcId" --output text)