Thuta Learning
BasicDevOpsbeginner

Your First EC2 Instance

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Understand Your First EC2 Instance without the intimidation
  • Be able to run the AWS CLI/Console yourself
  • Apply this concept immediately in a real project

Let's think about this for a second

An EC2 Instance represents a single virtual server — to launch one, you choose an AMI (Amazon Machine Image, a template containing an operating system plus pre-installed software), such as Ubuntu, Amazon Linux, or Windows Server. The Instance Type (t2.micro, t3.large) determines the CPU/memory size — t2.micro is Free Tier eligible and works well for learning. The Key Pair is the authentication method used to SSH into the instance (public/private key encryption) — if you don't create or select a key pair at launch time, you won't be able to get into the instance at all.

Let's connect this to a real scenario

In the EC2 launch wizard, configure the AMI (something like Amazon Linux 2023), Instance Type (t2.micro), Key Pair (create a new one), and Security Group (only allow SSH port 22 from your own IP), then hit Launch — within minutes your server is up and running, and you can connect with `ssh -i my-key.pem ec2-user@<public-ip>`.

Let's look at it together

bash
# Launch an EC2 instance via CLI (t2.micro, Amazon Linux)
aws ec2 run-instances \
  --image-id ami-0abcdef1234567890 \
  --instance-type t2.micro \
  --key-name my-key \
  --security-group-ids sg-0123456789abcdef0

# SSH into it once running
ssh -i my-key.pem ec2-user@<public-ip>
You should see
$ aws ec2 describe-instances --query 'Reservations[].Instances[].State.Name'
["running"]

5-minute try-it

Launch a t2.micro EC2 instance from the AWS Console (or the CLI) — try SSHing into it, and once you're done practicing, terminate (delete) the instance to avoid costs.

A quick word of caution

If you leave an EC2 instance running without terminating it after practice (and go past the Free Tier limit), you'll start racking up hourly costs — double-check your instance status after every lesson.

Easy traps

  • Forgetting to download the Key Pair at launch time — you can only download a key pair once, and if you lose it, you won't be able to SSH into the instance anymore
  • Opening the SSH port (22) to 'anywhere' (0.0.0.0/0) in the Security Group — you should only allow access from your own IP address

Now try it yourself

Launch a t2.micro EC2 instance from the AWS Console (or the CLI) — try SSHing into it, and once you're done practicing, terminate (delete) the instance to avoid costs.

You'll know it worked when: $ aws ec2 describe-instances --query 'Reservations[].Instances[].State.Name' ["running"]

Your First EC2 Instance | Thuta Learning