DEV Community

Cover image for What is AWS S3 and How I Used It — A Beginner's Guide
Prashik besekar
Prashik besekar

Posted on

What is AWS S3 and How I Used It — A Beginner's Guide

No theory overload. Just real, simple explanation from someone who actually used it.


Why I'm Writing This

When I first heard "S3 bucket" I thought — what does a bucket have to do with cloud storage? 😄

I was confused. Every tutorial I found was either too technical or too shallow. So after actually using S3 in my own projects, I decided to write the guide I wish I had when I started.

If you're a beginner trying to understand AWS S3 — this is for you.


So What Exactly is AWS S3?

S3 stands for Simple Storage Service.

Think of it like this — imagine Google Drive or Dropbox, but built for developers and applications. You can store any file — images, videos, PDFs, code files, database backups — and access them from anywhere in the world.

The things you store inside S3 are called objects.
The container that holds those objects is called a bucket.

Simple as that. 🪣


Why Do Developers Use S3?

  • It never goes down — AWS guarantees 99.999999999% durability (11 nines!)
  • It scales infinitely — store 1 file or 1 billion files, S3 handles it
  • It's cheap — you only pay for what you store and transfer
  • It's fast — files are served from AWS data centers worldwide
  • Free tier available — 5GB free storage for 12 months

In my own projects I used S3 to:

  • Store static website files
  • Save user uploaded images
  • Keep database backup files
  • Host assets for my web applications

Key Concepts You Must Know

1. Bucket

A bucket is like a folder at the top level. Every file you store in S3 lives inside a bucket.

Rules for buckets:

  • Bucket name must be globally unique across ALL of AWS
  • Choose a region close to your users for faster access
  • You can create multiple buckets for different purposes

2. Object

An object is any file you store — image, video, document, anything.
Every object has:

  • A key — basically the file name and path
  • A value — the actual file content
  • Metadata — information about the file

3. Access Control

By default everything in S3 is private. Only you can access it.
You can make specific files or entire buckets public if needed — like for a website.


Step by Step — How to Use S3

Step 1 — Create a Bucket

  1. Go to AWS Console → S3 → Create Bucket
  2. Enter a unique bucket name (example: "prashik-portfolio-files")
  3. Choose your region (ap-south-1 for Mumbai if you're in India)
  4. Keep "Block all public access" ON for now
  5. Click Create Bucket ✅

Step 2 — Upload a File

  1. Click on your bucket name
  2. Click Upload
  3. Drag and drop any file
  4. Click Upload

Your file is now stored in the cloud! 🎉

Step 3 — Access Your File

Click on the file → you'll see an Object URL.

If your bucket is private, this URL won't work publicly.
If you want to share it, you can generate a Pre-signed URL — a temporary link that expires after a time you choose.


How I Used S3 in My Project

In my AWS High Availability Architecture project I used S3 for:

1. Static Asset Storage
All images and frontend assets were stored in S3 instead of on the EC2 server. This way even if the server restarts, the files are safe.

2. CloudWatch Log Storage
I configured CloudWatch to export logs to an S3 bucket automatically. This way I had a permanent backup of all server logs.

3. EC2 Backup Files
I wrote a simple shell script that automatically backed up important files from EC2 to S3 every day.

#!/bin/bash
# Simple backup script to S3
DATE=$(date +%Y-%m-%d)
aws s3 cp /var/www/mywebsite s3://my-backup-bucket/backup-$DATE/ --recursive
echo "Backup completed: $DATE"
Enter fullscreen mode Exit fullscreen mode

This gave me peace of mind — even if the EC2 instance crashed, my files were safe in S3.


S3 with Node.js — Quick Example

Here's how to upload a file to S3 using Node.js:

const AWS = require('aws-sdk');

// Configure AWS
const s3 = new AWS.S3({
    accessKeyId: process.env.AWS_ACCESS_KEY,
    secretAccessKey: process.env.AWS_SECRET_KEY,
    region: 'ap-south-1'
});

// Upload file function
const uploadFile = async (fileName, fileContent) => {
    const params = {
        Bucket: 'your-bucket-name',
        Key: fileName,
        Body: fileContent
    };

    try {
        const data = await s3.upload(params).promise();
        console.log('File uploaded successfully:', data.Location);
        return data.Location;
    } catch (error) {
        console.error('Upload failed:', error);
    }
};

// Use it
uploadFile('profile-image.jpg', imageBuffer);
Enter fullscreen mode Exit fullscreen mode

Simple right? This is how real applications store user uploaded images on S3.


S3 Pricing — Don't Worry It's Cheap

For beginners the free tier covers:

  • 5 GB storage free for 12 months
  • 20,000 GET requests free
  • 2,000 PUT requests free

After free tier:

  • Storage: around $0.023 per GB per month
  • For a small project you'll spend less than $1/month

Common Mistakes Beginners Make

Mistake 1 — Making everything public
Never make your entire bucket public unless it's specifically for a static website. Keep sensitive files private always.

Mistake 2 — Storing AWS credentials in code
Never do this:

// WRONG ❌
accessKeyId: 'AKIAIOSFODNN7EXAMPLE'
Enter fullscreen mode Exit fullscreen mode

Always use environment variables or IAM roles.

Mistake 3 — Choosing wrong region
Choose the region closest to your users. For India — use ap-south-1 (Mumbai) for best performance.

Mistake 4 — Not versioning important files
Enable S3 versioning for important buckets. If you accidentally delete a file, you can recover it.


Quick Summary

Term Simple meaning
S3 Cloud storage service by AWS
Bucket Container that holds your files
Object Any file stored in S3
Key The file name/path
ACL Controls who can access your files
Pre-signed URL Temporary shareable link

What's Next?

Now that you understand S3, here's what to explore next:

  • S3 Static Website Hosting — host a complete website on S3 for almost free
  • S3 + CloudFront — deliver your files super fast worldwide using CDN
  • S3 Lifecycle Policies — automatically move old files to cheaper storage

I'll be writing about these in upcoming articles. Follow me so you don't miss them! 🙌


Final Thoughts

S3 is one of those AWS services you'll use in almost every real project. Once you understand it, a whole world of cloud architecture opens up.

Start simple — create a bucket, upload a file, access it. That's all it takes to begin.

And remember — the best way to learn AWS is to actually use it. Free tier gives you enough to experiment without spending a single rupee.

Go build something! 💪


Found this helpful? Follow me for more practical AWS and backend development content.

Connect with me:
LinkedIn: linkedin.com/in/prashik-besekar
GitHub: github.com/prashikBesekar

Top comments (0)