A hands-on VPC lab in twenty slides, in the console and the CLI: rebuild the bucket and the web server's role; create project-vpc with the "VPC only" option, four subnets in two AZs, an internet gateway and two route tables; add a NAT gateway, launch the web server into a private subnet with its role and user data, connect with Session Manager and prove the way out through NAT; remove the NAT route, then the internet gateway route, and trace each failure; add an S3 gateway endpoint and a bucket policy that lets only the role read through it; clean up the NAT gateway, its address and the rest.
The slides
The tool is a hands-on lab in twenty slides, one step each, with the steps to follow beside a terminal and a picture
of the VPC, its route tables, the bucket and the role:
- Introduction: what the lab builds.
- 1. What the lab needs
- Rebuild the bucket and the role:
firstname-lastname-project with index.html, and project-web-role with its instance profile, from the CLI.
- 2. The VPC
- Create the VPC:
project-vpc, 10.0.0.0/16, VPC only, with DNS hostnames on. - Create four subnets:
public-a, public-b, private-a, private-b. - Create the internet gateway:
project-igw, attached. - Create the public route table:
project-public-rt, with the route to the internet gateway. - Create the private route table from the CLI:
project-private-rt.
- 3. NAT and the web server
- Create the NAT gateway:
project-nat in public-a, with an Elastic IP address, and the private route to it. - Launch the web server into the private subnet: no public address, no key pair, the role and user data.
- Connect with Session Manager.
- Prove the way out through NAT:
checkip.amazonaws.com answers with the NAT gateway's address.
- 4. Break and fix the routing
- Remove the route to the NAT gateway, and put the route back.
- Remove the route to the internet gateway, trace it hop by hop, and put the internet gateway's route back.
- 5. The S3 gateway endpoint
- Create the S3 gateway endpoint: the prefix-list route in the private route table.
- Add the bucket policy: two Deny statements, on
aws:SourceVpce and aws:PrincipalArn. - Test the policy from both sides: the role through the endpoint,
jane from her computer. - Take the endpoint away from the private route table: the role refused through NAT.
- 6. Clean up: the NAT gateway and its address first, then Delete VPC, the bucket and the role.
The buttons on the left and right edges move between slides. So do the arrow keys and a swipe.
The lab follows
Amazon EC2 Lab: a Role and Session Manager, whose bucket and role
its first slide makes again, and works as jane, from
Getting Started with AWS.
The slides
Amazon VPC: a Network from Scratch explain what it uses.
The placeholders
The IDs are AWS's documentation placeholders (vpc-1234567890abcdef0, i-1234567890abcdef0), and the account is
111122223333. 203.0.113.25 stands for the NAT gateway's Elastic IP address. The instance's private address,
10.0.10.25, and the NAT gateway's, 10.0.0.84, are examples: yours come from the same subnets. S3's prefix list
pl-63a5400a is the real one in us-east-1.
Sources