Skip to main content

Command Palette

Search for a command to run...

Understanding AWS EC2 in Under 3 minutes

Updated
3 min read
K

Hi I am Krupa! I’m a Full-Stack Developer focused on building secure, scalable web applications with Java, JavaScript/TypeScript, and Node.js. I take pride in solving challenges like authentication and Single Sign-On. Off work, I’m a 2× marathon finisher and avid photographer, always seeking new adventures.

AWS EC2 (Elastic Compute Cloud) lets you rent virtual machines on demand in the cloud — pay only for what you use. It's like having your own server, but elastic, scalable, and ready in minutes.


Why Use EC2?

  • Elasticity: Scale up or down based on demand

  • Pay-as-you-go: Only pay for active time and resources

  • Fully configurable: Choose OS, hardware, storage, networking

  • Secure: IAM roles, SSH keys, and security groups protect your instances

Step-by-Step EC2 Setup

Let’s walk through the EC2 setup with the following example in mind. Say you’re building a handcrafted jewelry e-commerce app and want to deploy it on AWS for 100 users.

Your stack includes:

  • Frontend: React

  • Backend: Node.js / Express

  • Static assets: Product images

1. Choose an AMI (Amazon Machine Image)

An AMI is a pre-configured OS image (like Ubuntu or Windows).
It includes the OS and optional runtime packages.

For the E-commerce app
Use the Ubuntu Server 22.04 LTS AMI — it’s stable, well-supported, and works perfectly for a Node.js web server.

2. Choose an Instance Type

This defines the virtual hardware — CPU, memory, networking.

  • General Purpose (t3.small) – Balanced for small apps

  • Compute Optimized – For CPU-heavy tasks

  • Memory Optimized – For in-memory apps

  • Storage / GPU Optimized – For ML or big data

For the E-commerce app
Choose t3.small (2 vCPU, 2 GB RAM) — affordable and sufficient for up to 100 users. If you expect bursts, go for t3.medium.

3. Configure the Instance

Here you define how the instance behaves in your network.

  • Public IP: Enable auto-assign

  • IAM Role: Attach if you need S3 access

  • Shutdown behavior: Set to "Stop"

  • Number of instances: 1 (for now)

4. Add Storage

Attach volumes (disks) to your instance:

  • EBS (Elastic Block Store) = persistent block storage

  • Ephemeral storage = temporary, deleted on stop

  • S3 = external object storage (not directly mounted)

For the E-commerce app
Use 30 GB EBS as your root volume. Store images and static files in S3 buckets (linked via IAM)

5. Add Tags

Tags are key-value pairs to help identify and organize AWS resources.

For the E-commerce app
Add: Key: NameValue: jewelry-ec2-prod

6. Configure Security Group

Security groups act like virtual firewalls — they control inbound and outbound traffic to/from your instance.

For the E-commerce app
Allow: SSH (port 22) — from your IP only. HTTP (port 80) & HTTPS (port 443) — open to all

7. Review and Launch

  • Review your settings

  • Create a new key pair (RSA) — download the .pem file

  • This key is how you SSH (log in) to your EC2 securely

Note for Windows users:
Use PuTTY + PuTTYgen to convert .pem.ppk and log in to your EC2 instance.

After Setup: Deploying Your Jewelry Website

Once your EC2 is live, you can deploy your static site using one of the following:

  • Nginx – Best choice for static sites, fast and production-ready

  • Apache – Good alternative, heavier than Nginx

  • http-server or python3 -m http.server – Quick dev/testing tools

  • Docker – For running containerized apps

💡 Nginx is the most common choice — it’s lightweight, fast, secure, and works great for serving static files.

Final Thought

AWS EC2 gives you the flexibility, control, and scalability to run anything from a static website to a full production app — all without owning a single physical server.