Stop 18 · Cloud & HostingTopics · 2/11

AWS EC2

Part of the Backend Developer Roadmap

In short

EC2 is a computer in Amazon's data centre that you rent by the second. You pick the size, get SSH access, and it's yours to set up, secure and occasionally break.

Amazon's Elastic Compute Cloud — rentable virtual servers you configure and manage yourself, giving full control at the cost of more operational responsibility.

The purple blob picks up keys at a rental lot with a hatchback, sedan and van parked in a row.

Think of it like this

Self-drive car rental

You pick a hatchback or an SUV, take the keys and drive. Fuel, parking and dents are your problem, and the meter runs until you return it. EC2 is the same: choose an instance type, get the SSH key, and you're billed until you stop it.

Watch it happen

From nothing to a running server

You
AWS
EC2 instance

run-instances t3.micro

1/5You ask AWS for a small instance from an Ubuntu AMI, the disk image it boots from.

The big ideas

What you need to know

Instance types

Names like t3.micro or m7i.large describe the family and size. Start small, measure, then resize.

Security groups

A virtual firewall. Allow 22 only from your IP, 80 and 443 from everyone, and nothing else.

EBS disks

The root disk is a network volume. It survives stop and start, but is deleted on termination by default.

Elastic IP

A stopped and restarted instance gets a new public IP. Attach an Elastic IP or a load balancer for a fixed address.

See it in code

Walk through the code

bash
1aws ec2 run-instances \2  --image-id ami-0abcd1234example \3  --instance-type t3.micro \4  --key-name my-laptop \5  --security-group-ids sg-0123example \6  --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=api-1}]'7 8# Then, from your laptop:9chmod 400 my-laptop.pem10ssh -i my-laptop.pem ubuntu@<public-ip>11sudo apt update && sudo apt install -y nginx

1/4Pick the operating system image and the machine size.

Replace the AMI and security group IDs with real ones from your region. The console's launch wizard does exactly this call for you.

Save yourself the pain

Common mistakes

Oops

Opening port 22 to 0.0.0.0/0, the whole internet.

Do this instead

Bots scan for open SSH constantly. Allow only your own IP, or use AWS Systems Manager Session Manager instead.

Oops

Treating one hand-configured EC2 box as precious.

Do this instead

Script the setup with user data, a Dockerfile or Ansible, so you can rebuild the server in minutes if it dies.

Your mission

Launch, deploy, destroy

~40 min

Quick check

You stop an EC2 instance overnight and start it in the morning. Your DNS record now points nowhere. Why?

Go deeper

  1. 1Launch a free-tier EC2 instance and SSH into it.
  2. 2Deploy a simple Node app on it manually, end to end.
  3. 3Learn why most teams eventually move from manual EC2 management to more automated deployment tooling.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge