AWS Builder Center
Launch Your First EC2 Instance Without the Surprise Bill: A Beginner’s Guide

Launch Your First EC2 Instance Without the Surprise Bill: A Beginner’s Guide

Launch a small virtual server on AWS, connect to it, understand what it costs and shut it all down properly.

You've heard that AWS lets you rent a computer in the cloud. Then you launch one, close the tab, and forget about it. A few weeks later there's a charge on your bill.
Amazon EC2 is where many beginners start, and it's also where a few simple habits matter most.
So here's the challenge: Can we launch our first EC2 instance, connect to it and clean it up completely, with no leftovers?

1. The Idea in 30 Seconds

You (SSH from your own IP)
|
v
Security group (port 22, your IP only)
|
v
EC2 instance (small Linux server) --- EBS volume (its disk)
A few terms you'll see:
  • Instance: a virtual server running in an AWS data center.
  • AMI: the template (operating system and software) the instance starts from.
  • Instance type: the size of the server, such as  t3.micro . Bigger costs more.
  • EBS volume: the disk attached to your instance.
  • Security group: a firewall that decides who can connect.
  • Key pair: the file you use to prove who you are when you connect over SSH.

2. Launch the Instance

  1. In the console, choose your Region, open EC2 and choose Launch instance.
  1. Name it  ec2-challenge .
  1. Pick Amazon Linux as the AMI.
  1. Pick an instance type marked Free tier eligible if your account shows one. Otherwise choose a small type such as  t3.micro  and check its price first.
  1. Under Key pair, create a new one and download the  .pem  file. You only get it once, so keep it safe.
  1. Under Network settings, allow SSH from My IP only. Never leave it open to  0.0.0.0/0 , which means the whole internet.
  1. Keep the default small root volume.
  1. Choose Launch instance.

3. Connect to It

When the instance shows Running, copy its public DNS name from the instance details and connect from your terminal:
chmod 400 my-key.pem
ssh -i my-key.pem ec2-user@<public-dns-name>
If you land at a command prompt, you're on your own cloud server. Try  uname -a  to see what it's running, then type  exit  to leave.

4. Three Habits That Prevent Surprises

Set a budget alert first. A small monthly budget with email alerts in AWS Budgets takes a few minutes and warns you early.
Pick small and short. The larger the instance type, the faster the bill grows. Learn on the smallest one that works.
Remember the Region. Resources live in one Region, and the console only shows the Region you've selected. Forgotten instances often hide in a Region you're not looking at.

5. Stopped Is Not the Same as Terminated

This is the part that surprises most beginners.
State
Instance hours
EBS volume
Public IPv4 address
Running
Billed
Billed
Billed
Stopped
Not billed
Still billed
Auto-assigned address is released, but an Elastic IP is still billed
Terminated
Not billed
Root volume is deleted by default
Released
Stopping pauses the server but keeps its disk, so you keep paying for storage. When you're finished with an instance for good, terminate it.

6. What Can Cost Money

  • Instance hours while it's running.
  • EBS volumes for as long as they exist, even attached to a stopped instance.
  • Public IPv4 addresses, which AWS charges for by the hour.
  • Elastic IPs you've allocated but aren't using.
  • Data transfer out to the internet.
  • Snapshots and AMIs you create along the way.
What's free depends on your account plan, so check your own plan and the current prices:  https://aws.amazon.com/ec2/pricing/ 

7. Clean Up Completely

First find your instances. Run this for each Region you used:
aws ec2 describe-instances \
--query "Reservations[].Instances[].[InstanceId,InstanceType,State.Name]" \
--output table
Then terminate the one you launched (replace the ID with yours):
aws ec2 terminate-instances --instance-ids i-0123456789abcdef0
Cleanup checklist:
  • Terminate the instance and wait until it shows Terminated.
  • Open Volumes and delete any that are left over.
  • Release any Elastic IPs.
  • Delete snapshots and AMIs you created.
  • Delete the key pair and the  .pem  file if you no longer need them.
  • Check every Region you used, then glance at Billing and Cost Management.

Conclusion: Take the EC2 Challenge!

Launching a server is the easy part. The real skill is knowing what keeps costing money after you walk away and shutting it all down on purpose.
Your turn: What was the first thing you ran on your own cloud server? Did you ever find a forgotten instance?
Share it in the comments!

Official resources

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article