This content originally appeared on DEV Community and was authored by AKASH S
First Things First β Whatβs EC2?
So basically, EC2 stands for Elastic Compute Cloud.
Now, if someone coming from using physical machines or on-premise servers, here’s the shift β instead of maintaining those heavy, costly, and fixed systems, we now use virtual servers in the cloud. These are much more flexible, scalable, and cost-effective.
EC2 is just AWSβs version of this virtual computer.
We can launch it anytime, choose our operating system, configure its specs, and access it from anywhere β all through the internet. And not just AWS, almost every cloud provider offers a similar service with different names.
Hereβs what I learned as I explored EC2. These are not definitions, just what I personally understood through hands-on work:
1. Name of the Machine
When we launch an instance, give it a proper name β something like akash-dev-machine
2. AMI (Amazon Machine Image)
- Think of this like the OS setup file (kind of like an ISO file). AWS already gives us pre-configured images.
- We just choose what we need:
- Ubuntu, Amazon Linux, Windows, etc.
- Itβs up to our project.
3. Instance Type
Now this is where I got a bit confused at first, but here’s how I made sense of it:
- General Purpose β Balanced CPU and RAM (1:1 ratio)
- Compute Optimized β More CPU-heavy stuff (2:1 ratio)
- Memory Optimized β Big data and memory-based tasks (1:2)
- Storage Optimized β Better for IOPS and file-heavy operations
- Accelerated Computing β GPU instances for ML, video rendering, etc.
- HPC β High-performance computing stuff
As we’re on Free Tier (like me when I started), we mostly use t2.micro or t3.micro
.
4. Key Pair (Very Important)
This part is all about secure login.
- weβll create a key pair during EC2 launch.
- AWS stores the public key in the EC2 instance.
- Download the private key (the .pem file).
- Itβs kind of like a door lock
and our own key
. we need this .pem file every time we want to SSH or RDP into the machine.
5. Security Groups
This is like your instanceβs firewall.
Here, we define:
- What ports should be open,
- Who can access them,
- From which IPs.
Some common ports:
- 22 β SSH (Linux)
- 3389 β RDP (Windows)
- 80 β HTTP (Web traffic)
- 443 β HTTPS
Real-World Example
Letβs say we have:
- One EC2 for our website (public).
- One EC2 for our admin panel (private). For the public one, allow traffic from anywhere (0.0.0.0/0). For the admin one, allow only our IP. That way, it’s secure.
6. Hosting Webpages on EC2
On Windows:
- Use IIS (Internet Information Services).
- Our default folder will be something like: C:\inetpub\wwwroot
- Paste our HTML files there and access via EC2 IP in a browser.
On Linux:
- weβll need to install and start the HTTP server (Apache).
- Paste our HTML files into /var/www/html/.
- Open the IP in a browser and β it works.
7. Transferring Files Between Local and EC2
If wou want to share files:
- Use WinSCP
- Just paste our EC2βs public IP, choose our key file, and we’re in.
- Itβs super handy for moving project files, images, and logs.
Wrapping Up
- This is not some βtutorialβ post.
- I just wanted to put down everything I actually understood after playing around with EC2 for weeks.
- From launching an instance, accessing it, setting up networking and security β all of it made me feel like, βYeah, Iβm finally getting how the cloud works.β
- If you’re starting with AWS, start with EC2. Itβs your foundation for understanding other services.
More on the way. Keep an eye out!
This content originally appeared on DEV Community and was authored by AKASH S