AWS Builder Center
AWS Compute Series — Day 1: Amazon EC2

AWS Compute Series — Day 1: Amazon EC2

Understanding Virtual Servers in the Cloud

Series: AWS Compute Series (5 articles)

  1. 1
    AWS Compute Series — Day 1: Amazon EC2 This article
DevOps & Software Engineering
In our  previous post , we explored the evolution of IT infrastructure:
 On-Premises → Virtualization → Cloud Computing 
Now, let's look at one of the fundamental services that made cloud computing practical for organizations: Amazon Elastic Compute Cloud (EC2).
But first, a simple question:
What happens when a company needs a server to host its application?
Traditionally, it had to purchase physical hardware, install it, configure the operating system, prepare networking and security, and maintain the infrastructure.
With Amazon EC2, the company can provision a virtual server on AWS infrastructure in minutes.
Let's understand how.

1. What is Amazon EC2?

Amazon EC2 is an AWS service that provides resizable computing capacity in the cloud.
In simple terms, it allows you to create and manage virtual servers called EC2 instances, without purchasing the physical servers yourself.
You can use an instance to:
  • Host a web application.
  • Run a backend API.
  • Deploy a database (when appropriate for the architecture).
  • Execute background jobs.
  • Run development and testing environments.
  • Host enterprise workloads.
EC2 does not eliminate servers. It changes how we provision, consume and manage them.

2. How does an EC2 instance work?

Think of an EC2 instance as a virtual machine running on AWS-managed physical infrastructure.
When launching an instance, you make several important choices.

A. Amazon Machine Image (AMI)

An AMI is a template used to launch an EC2 instance.
It provides the information needed to create the instance, including the operating system and potentially preconfigured software.
Examples:
  • Amazon Linux.
  • Ubuntu Server.
  • Windows Server.
Think of an AMI as the starting blueprint for your server.

B. Instance Type

The instance type determines the computing resources available to your server.
It defines characteristics such as:
  • Virtual CPUs (vCPUs).
  • Memory (RAM).
  • Network performance.
  • Storage characteristics supported by the instance.
Different workloads need different resources.
For example:
  • A lightweight API may need modest computing capacity.
  • A memory-intensive application may need more RAM.
  • A compute-intensive workload may need more processing power.
Choosing the right instance type is an architectural and cost decision, not just a technical preference.

C. Storage

An EC2 instance can use different storage options.
The two important concepts to understand are:
  • Amazon EBS (Elastic Block Store): persistent block storage that can remain available independently of the running state of an instance.
  • Instance Store: temporary storage physically associated with the host, whose data does not persist through certain instance lifecycle events.
Important distinction: stopping an EBS-backed instance does not normally delete its EBS volumes. However, instance-store data is ephemeral.

D. Networking

Every EC2 instance operates within an AWS network, typically an Amazon VPC.
Its networking configuration determines how it communicates with other resources and, when configured, the internet.
Important concepts include:
  • VPC: your logically isolated network.
  • Subnet: a network segment within the VPC.
  • Private and public IP addresses.
  • Route tables.
  • Internet Gateway and NAT Gateway.
We'll explore these networking concepts in detail during our Networking series.

E. Security Groups

A Security Group acts as a virtual firewall associated with an EC2 instance's network interface.
It controls inbound and outbound traffic through rules.
For example:
  • SSH (port 22): administrative access on Linux.
  • RDP (port 3389): remote desktop access on Windows.
  • HTTP (port 80): web traffic.
  • HTTPS (port 443): encrypted web traffic.
Security Groups are stateful: permitted traffic in one direction allows the corresponding response traffic.
A critical security principle: never expose administrative access to the entire internet unnecessarily.

F. Key Pairs

Key pairs provide a way to authenticate to supported EC2 instances.
For Linux instances, an SSH private key is commonly used for secure remote access.
The private key must be protected. Losing control of it can compromise access to your server.

3. What happens when you launch an EC2 instance?

Let's connect the concepts.
 AMI → Instance Type → Storage → Network → Security Configuration → EC2 Instance Running 
In practice:
  1. Select an AMI.
  1. Choose an instance type.
  1. Configure storage.
  1. Select the VPC and subnet.
  1. Configure network access and security groups.
  1. Configure authentication.
  1. Launch the instance.
  1. Connect and configure your workload.
Once the instance is running, you can install software, deploy applications, monitor performance and manage its lifecycle.

4. Understanding the EC2 lifecycle

An EC2 instance does not simply exist in a permanent running state.
Its lifecycle includes several important states:
  • Pending: AWS is preparing the instance.
  • Running: the instance is operational.
  • Stopping: AWS is stopping the instance.
  • Stopped: compute billing for the instance has stopped, but other resources may still incur charges.
  • Shutting-down: the instance is being terminated.
  • Terminated: the instance has been permanently deleted.
Remember: stopping an instance is not the same as terminating it.
Also, stopping an instance does not automatically eliminate all costs. EBS volumes, snapshots, Elastic IP addresses and other associated resources may still generate charges depending on their configuration.

5. How does EC2 change the economics of infrastructure?

Let's compare two approaches.
Traditional infrastructure — CAPEX
An organization purchases physical servers, invests in equipment and plans capacity ahead of demand.
Cloud infrastructure — OPEX
With EC2, an organization can consume computing capacity and pay according to its selected pricing model.
AWS offers several purchasing options, including:
  • On-Demand Instances.
  • Savings Plans and Reserved Instances.
  • Spot Instances.
The right choice depends on workload duration, predictability, flexibility and interruption tolerance.
EC2 also supports elasticity through services such as EC2 Auto Scaling, allowing organizations to adjust the number of instances based on demand.
However, cloud does not automatically mean cheaper infrastructure.
Poor resource sizing, forgotten instances and unnecessary storage can create unexpected expenses.

6. When should you use EC2?

EC2 is particularly useful when you need:
  • Control over the operating system.
  • Custom software installation.
  • Flexible computing capacity.
  • Support for applications that require a traditional server environment.
  • Specific configurations that managed services may not expose.
But EC2 is not always the best choice.
If you only need to execute code in response to events without managing servers, AWS Lambda may be more appropriate.
If you need managed container orchestration, Amazon ECS or Amazon EKS may be worth considering.
Choosing an AWS service starts with understanding the problem, not selecting the most popular product.

7. What about security and responsibility?

AWS manages the security of the underlying cloud infrastructure.
But customers remain responsible for securing what they deploy in the cloud.
For EC2, this includes responsibilities such as:
  • Operating system updates and patching.
  • Identity and access management.
  • Network access restrictions.
  • Application security.
  • Data protection.
  • Monitoring and incident response.
This is part of the AWS Shared Responsibility Model.
Having a virtual server in AWS does not automatically make the application secure.

8. The practical takeaway

Amazon EC2 is more than a virtual server.
It brings together computing, storage, networking, security and infrastructure management into a service that organizations can provision and scale on demand.
To understand EC2 properly, you should be able to answer these questions:
  • What is an AMI?
  • How does an instance type affect performance and cost?
  • What is the difference between EBS and Instance Store?
  • What does a Security Group control?
  • What happens when an instance is stopped or terminated?
  • How can you scale EC2 capacity?
Understanding these fundamentals is more valuable than simply knowing how to click Launch Instance.
Coming next in our Compute journey: AWS Lambda — understanding serverless computing and why not every workload needs a server that you manage.
Learn • Build • Share • Certify

Series: AWS Compute Series (5 articles)

  1. 1
    AWS Compute Series — Day 1: Amazon EC2 This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article