๐ Day 18 of 30 Days DevOps Interview Preparation: AWS EC2 โ Launch VM & Connect with Key

Series: 30 Days DevOps Interview Preparation
Author: Tathagat Gaikwad
Cloud computing is at the heart of modern DevOps, and if youโre preparing for roles like DevOps Engineer, Cloud Engineer, or SRE, you cannot skip AWS EC2.
In this blog, weโll cover:
What is AWS EC2?
Step-by-step practical guide: Launching a VM on AWS and connecting with a key
Best practices for EC2 security & usage
Common EC2 interview questions (with answers)
๐น What is AWS EC2?
AWS Elastic Compute Cloud (EC2) provides resizable virtual machines (instances) in the cloud. It allows developers and DevOps engineers to:
Run applications without investing in physical hardware.
Scale up or down on demand.
Pay only for the compute power used.
Think of it as renting a computer from AWS thatโs always available, secure, and customizable.
๐น Step-by-Step Practical: Launch & Connect to EC2
Hereโs how you can launch your first VM in AWS:
1. Log in to AWS Console
Go to AWS Management Console.
Search for EC2 in the services.
2. Launch an Instance
Click Launch Instance.
Choose an Amazon Machine Image (AMI) like Amazon Linux 2 or Ubuntu 20.04.
3. Choose Instance Type
- For beginners/free tier โ t2.micro (1 vCPU, 1GB RAM).
4. Configure Key Pair
Create a new Key Pair (.pem file).
Download it securely (needed for SSH).
5. Configure Security Groups
Allow SSH (port 22) for your IP.
Optionally, allow HTTP (80) and HTTPS (443) if you plan to deploy a web app.
6. Launch & Connect
Once the instance is running, copy the Public IP.
Open terminal and run:
chmod 400 mykey.pem
ssh -i mykey.pem ec2-user@<Public-IP>
โ Youโre now inside your cloud VM! ๐
๐น Best Practices for AWS EC2
Restrict SSH access to your IP only (never 0.0.0.0/0 for prod).
Always use Key Pairs for login (avoid passwords).
Assign an Elastic IP if you need a static IP.
Use IAM roles instead of embedding AWS credentials in code.
Enable CloudWatch monitoring to track performance.
๐น Common AWS EC2 Interview Questions & Answers
Q1. What is an AMI in AWS EC2?
๐ An AMI (Amazon Machine Image) is a pre-configured template containing OS, software, and configurations used to launch an instance.
Q2. How do you connect securely to an EC2 instance?
๐ Using SSH with the .pem key pair file generated during instance creation.
Q3. Whatโs the difference between On-Demand, Spot, and Reserved Instances?
๐
On-Demand: Flexible, pay-per-use.
Spot: Cheaper (up to 90% off), but AWS can reclaim anytime.
Reserved: 1โ3 year commitment, cost-effective for stable workloads.
Q4. What if you canโt SSH into your EC2 instance?
๐ Troubleshooting steps:
Check if the Security Group allows inbound SSH (port 22).
Ensure correct key permissions (
chmod 400
).Verify instance Public IP/DNS.
Confirm instance state is Running.
Q5. How does EC2 integrate into a DevOps pipeline?
๐ EC2 serves as compute resources where CI/CD runners, apps, or containerized workloads are deployed and tested.
๐น Hands-On Demo Idea for Practice
๐ Deploy a simple Nginx Web Server on your EC2:
sudo yum update -y
sudo amazon-linux-extras install nginx1 -y
sudo systemctl start nginx
sudo systemctl enable nginx
Visit http://<EC2-Public-IP>
โ You should see the Nginx welcome page ๐
This makes your learning more practical and helps in interviews when asked:
"Have you deployed an app on AWS EC2?"
๐น Final Takeaway
AWS EC2 is one of the first building blocks youโll encounter in your DevOps journey. From deploying test apps to scaling production workloads, EC2 is everywhere.
๐ Key Learning for Day 18:
How to launch & connect to an EC2 instance.
Security best practices.
Core interview Q&A.
๐ฅ Stay tuned for Day 19: More AWS hands-on as we continue this 30 Days DevOps Interview Prep Challenge.
๐ Follow me here and on LinkedIn for daily DevOps prep content!
#AWS #DevOps #EC2 #CloudComputing #SRE #InterviewPreparation #30DaysOfDevOps
Subscribe to my newsletter
Read articles from Tathagat Gaikwad directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
