Servers and networks: EC2 and VPC
Launch a virtual server and understand the private network and firewall around it.
EC2 (Elastic Compute Cloud) gives you virtual servers called instances. You choose an AMI (the operating system image), an instance type (CPU and memory), storage and a network.
Your private network: the VPC
A VPC (Virtual Private Cloud) is your isolated network inside AWS. You give it an address range in CIDR notation, for example 10.0.0.0/16, and split it into subnets that live in one Availability Zone each. A public subnet has a route to an internet gateway. A private subnet does not.
Security groups
A security group is a virtual firewall attached to an instance. It lists allowed inbound and outbound traffic by protocol, port and source. Everything not allowed is blocked.
| Rule | Meaning |
|---|---|
| TCP 443 from 0.0.0.0/0 | HTTPS from anywhere. Fine for a public web server |
| TCP 22 from your IP /32 | SSH only from your address |
| TCP 5432 from the app security group | Database reachable only from the app servers |
CarefulNever open SSH (port 22) or a database port to 0.0.0.0/0. Automated scanners find them within minutes.
Connecting
ssh -i my-key.pem ec2-user@<public-ip>NoteStop an instance when you do not need it: you stop paying for compute, but you still pay for its disk. Terminate it to delete it.
Test yourself
Answer all the questions, then check them. Finish with every answer right to mark the lesson as done.