DEV Community

Cover image for How to Spin Up an AWS EC2 Instance: A Step-by-Step Guide for Software Engineers
Prateek Agrawal
Prateek Agrawal

Posted on

1 1 1

How to Spin Up an AWS EC2 Instance: A Step-by-Step Guide for Software Engineers

☁️ Why AWS EC2 Matters for DevOps Recruiters

As organizations shift to cloud-native architectures, AWS EC2 (Elastic Compute Cloud) remains the go‑to service for provisioning scalable virtual machines. Understanding how to spin up an EC2 instance is a foundational skill for Software Developers looking into the ocean of Devops field:

✔️ Build and maintain CI/CD pipelines

✔️ Host backend services, microservices, and frontend applications

✔️ Automate infrastructure with Terraform, Ansible, or CloudFormation

✔️ Create reliable staging and testing environments on demand

🚀 Quick Prerequisites

Before you begin, make sure you have:

  • An AWS Account – Sign up at aws.amazon.com

  • IAM Permissions – Access to create EC2 instances, security groups, and key pairs

  • AWS CLI (optional) – Install and configure with aws configure

  • SSH Client – Terminal on macOS/Linux or PowerShell/WSL on Windows

🔧 Step‑by‑Step: Spin Up Your First EC2 Instance

1️⃣ Log In & Navigate to EC2

  • Visit AWS Management Console.

  • Search for EC2 in the Services menu.

2️⃣ Launch New Instance

  • Click Launch Instance.

  • Name it (e.g., devops-ubuntu-server).

  • Select an AMI (Ubuntu Server 22.04 LTS is a solid choice).

  • Choose t2.micro (Free Tier eligible) or another size based on workload.

3️⃣ Configure Key Pair & Security

  • Under Key pair, create or select an existing key. Download the .pem file.

  • In Security Group settings, allow:

  • SSH (port 22) from your IP

  • HTTP (80) / HTTPS (443) if you plan to host a web app

4️⃣ Review & Launch

  • Double‑check storage (8 GB SSD default) and tags.

  • Click Launch, then View Instances. Wait for the state to turn running.

5️⃣ Connect via SSH


chmod 400 devops-key.pem

ssh -i devops-key.pem ubuntu@<public-ip>
Enter fullscreen mode Exit fullscreen mode

📦 Usage of EC2 in Modern DevOps

  • CI/CD Agents: Run build and test jobs on dedicated EC2 runners.

  • App Hosting: Deploy microservices or monoliths with auto-scaling groups.

  • Infrastructure as Code: Automate provisioning with Terraform modules or CloudFormation stacks.

  • Ephemeral Environments: Create isolated dev/staging servers and tear them down post‑testing.

  • Monitoring & Logging: Host Prometheus, Grafana, or the ELK stack on demand.

🚀 Motivations & Best Practices

  • Scalability: Instantly scale up/down based on traffic or testing needs.

  • Automation-Ready: EC2 integrates seamlessly with AWS SDKs and CLI for fully scripted workflows.

  • Cost Optimization: Leverage Spot Instances or Reserved Instances to reduce spend.

  • Security First: Enforce least-privilege IAM roles, use SSH key pairs, and lock down security groups.

  • Environment Parity: Replicate production topology for QA, reducing “it works on my machine”_ issues.

💬 If you found this guide helpful, feel free to share or leave a comment!

🔗 Connect with me online:

👨‍💻 Prateek Agrawal

prateek-bka (Prateek Agrawal) · GitHub

🚀 Full Stack Developer (MERN, Next.js, TS, DevOps) | Build scalable apps, optimize APIs & automate CI/CD with Docker & Kubernetes 💻 - prateek-bka

favicon github.com

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (2)

Collapse
 
nevodavid profile image
Nevo David

Pretty cool how starting a server on AWS is just a few clicks now; almost like turning on a light switch for the cloud.

Collapse
 
prateekbka profile image
Prateek Agrawal

Totally agree, it is as easy as flipping a light switch! ⚡ I’ve got tons of practical, bite‑sized tips on DevOps, CI/CD, and more coming your way—made just for developers. Stay tuned! 😊🚀

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

Billboard image

Try REST API Generation for MS SQL Server.

DevOps for Private APIs. With DreamFactory API Generation, you get:

  • Auto-generated live APIs mapped from database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Dive into this thoughtful article, cherished within the supportive DEV Community. Coders of every background are encouraged to share and grow our collective expertise.

A genuine "thank you" can brighten someone’s day—drop your appreciation in the comments below!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found value here? A quick thank you to the author makes a big difference.

Okay