Creating the Internet Gateway
The Internet gateway is the prerequisite for the NAT gateway, which will be created later.
To create the internet gateway and attach it to the VPC:
- Run the following command:
aws ec2 create-internet-gateway
Example output:
{ "InternetGateway":{ "Tags":[ ], "InternetGatewayId":"igw-0ddcfa7511fe10b43", "Attachments":[ ] } }
- Record the value of
InternetGatewayId
in your AWS worksheet. - Optionally, you might tag the internet gateway by running the following command:
aws ec2 create-tags --resources <InternetGatewayId> --tags Key=Name,Value=<internet gateway name>
- Attach the internet gateway to your previously-created VPC by running the following command (command has no output):
aws ec2 attach-internet-gateway --internet-gateway-id <InternetGatewayId> --vpc-id <VPC Id>
For example:
aws ec2 attach-internet-gateway \
--internet-gateway-id igw-0ddcfa7511fe10b43 \
--vpc-id vpc-0143197ca9bd9c117
Next Step: Creating the NAT Gateway