Knowing how to spin up an AWS EC2 instance is a core skill for software engineers who manage cloud infrastructure. EC2 gives you a virtual machine in AWS with direct control over the operating system, compute size, network rules, storage, and software. That control makes it a practical base for backend services, CI/CD agents, test environments, and infrastructure automation.
Key points
- EC2 is the AWS service for resizable virtual machines in the cloud.
- A launch requires an AMI, instance type, key pair, security group, and storage.
- Restrict SSH access to trusted IPs and use least-privilege IAM roles from day one.
What AWS EC2 is
EC2 stands for Elastic Compute Cloud. It provides resizable compute capacity as virtual machines running on AWS-managed hardware. You choose an AMI that defines the operating system and initial configuration, then pick an instance type that defines vCPU, memory, network capacity, and storage options.
Because EC2 is infrastructure as a service, you manage the guest OS, patches, agents, and application runtime. That differs from serverless services where AWS abstracts the host away.
Prerequisites for launching an EC2 instance
Before launching an instance, make sure you have:
- An AWS account. Sign up at aws.amazon.com.
- IAM permissions to create EC2 instances, key pairs, and security groups.
- AWS CLI optionally installed and configured with
aws configureif you want to automate the process. - An SSH client: Terminal on macOS or Linux, PowerShell or WSL on Windows.
How to spin up an AWS EC2 instance
This flow shows the main path from console to SSH:
Pick a region and AMI
Open the AWS Management Console and search for EC2. Choose the region where you want the instance. Region affects latency, cost, and data residency. Then click Launch Instance.
Name the instance so it is easy to identify later, such as devops-ubuntu-server. Choose an AMI. The AMI contains the operating system, architecture, and root volume template.
| AMI | Best for | Notes |
|---|
