0%
AWS EC2 & S3 Essentials: Simple Guide for Beginners

AWS EC2 & S3 Essentials: Simple Guide for Beginners

Learn the basics of AWS EC2 and S3 in plain English. See real‑world examples, quick tips, and step‑by‑step code to launch servers and store files.

Saransh Pachhai
Saransh Pachhai
4 min read41 viewsJune 1, 2026
awsec2s3cloud computingbeginners guide
Share:

AWS EC2 & S3 Essentials: Simple Guide for Beginners

Welcome! If you have ever wondered how to run a web server or keep files safe in the cloud, you are in the right place. This guide will walk you through the two most popular AWS services: EC2 (Elastic Compute Cloud) and S3 (Simple Storage Service). No heavy jargon, just clear examples and easy steps.

What is EC2?

EC2 is a virtual computer that lives in Amazon’s data centers. Think of it as renting a PC that you can start, stop, or change any time. You choose the size (CPU, memory, storage) that fits your workload.

Key points:

  • Instance: The name Amazon uses for a virtual server.
  • AMI: Amazon Machine Image – a template that includes an OS and optional software.
  • Region: Physical location of the data center (e.g., us-east-1, eu-central-1).

Why use EC2? You get full control over the OS, you can install anything you want, and you only pay for what you use.

Getting Started with EC2

Let’s launch a tiny Linux server using the AWS Command Line Interface (CLI). If you don’t have the CLI installed, grab it from aws.amazon.com/cli and run aws configure to add your credentials.

aws ec2 run-instances \
  --image-id ami-0c02fb55956c7d316 \
  --instance-type t2.micro \
  --key-name my-key-pair \
  --security-groups my-sg \
  --count 1

This command does a few things:

  • Uses an Amazon Linux AMI (the image ID above).
  • Selects a t2.micro instance – free‑tier eligible.
  • Attaches an SSH key so you can log in later.
  • Applies a security group that controls inbound/outbound traffic.

After a minute, the instance is ready. To connect via SSH:

ssh -i my-key-pair.pem ec2-user@

Replace my-key-pair.pem with the path to your private key and the placeholder with the instance’s public DNS name (found in the console).

Tip: Use aws ec2 describe-instances to list your instances and grab the DNS automatically.

What is S3?

S3 is a place to store files (objects) in the cloud. It works like a giant online folder that can hold any type of data – images, videos, logs, backups, you name it.

Important terms:

  • Bucket: A container for objects. Bucket names must be globally unique.
  • Object: The actual file stored inside a bucket.
  • Key: The full path/name of the object within the bucket.

S3 is highly durable (99.999999999% durability) and you can set permissions so only you or selected users can read or write.

Using S3 for File Storage

Let’s create a bucket and upload a file using the CLI.

# Create a bucket (replace my‑unique‑bucket‑123 with your own name)
aws s3 mb s3://my-unique-bucket-123

# Upload a local file
aws s3 cp ./example.txt s3://my-unique-bucket-123/example.txt

# List objects in the bucket
aws s3 ls s3://my-unique-bucket-123

That’s it! Your file lives safely in S3. You can access it via a URL like https://my-unique-bucket-123.s3.amazonaws.com/example.txt if the bucket is public.

Real‑world example: A web app might store user‑uploaded images in S3, then serve them directly to browsers without ever touching the EC2 instance.

Putting EC2 and S3 Together

Most production setups use both services. Here’s a simple scenario:

  1. Launch an EC2 instance to run your web application.
  2. Create an S3 bucket to hold static assets (images, CSS, JavaScript).
  3. Give the EC2 instance an IAM role that allows s3:PutObject and s3:GetObject on the bucket.
  4. From your app code, upload files to S3 and store the returned URL in a database.

Sample Python snippet using boto3 (AWS SDK for Python) to upload a file:

import boto3
s3 = boto3.client('s3')
bucket_name = 'my-unique-bucket-123'
file_path = 'photo.jpg'
key = f'uploads/{file_path}'

s3.upload_file(file_path, bucket_name, key)
print(f'File uploaded to https://{bucket_name}.s3.amazonaws.com/{key}')

Because the EC2 instance has the right IAM role, you don’t need to embed access keys in your code – AWS handles it securely.

Actionable Takeaways

  • Start with a t2.micro EC2 instance and an S3 bucket in the same region to minimize latency.
  • Use the AWS CLI for quick, repeatable steps. Save commands in a script for future use.
  • Always assign an IAM role to EC2 instead of hard‑coding credentials.
  • Set bucket policies or ACLs to control who can read or write objects.
  • Monitor costs: EC2 runs hourly, S3 charges per GB stored and per request.

Now you have the fundamentals to spin up a server, store files, and connect the two services. Experiment, break things, and learn – AWS makes it easy to start small and grow big.

Next Steps

Try these mini‑projects:

  • Host a static website directly from an S3 bucket.
  • Set up a simple Node.js app on EC2 that uploads user photos to S3.
  • Enable versioning on an S3 bucket to keep old copies of files.

Happy cloud building!

Loading comments...

Designed & developed with❤️bySaransh Pachhai

©2026. All rights reserved.

AWS EC2 & S3 Essentials: Simple Guide for Beginners | Saransh Pachhai Blog