Amazon EC2 (Elastic Compute Cloud)
Scalable, resizable compute capacity in the AWS Cloud
What is Amazon EC2?
Amazon Elastic Compute Cloud (Amazon EC2) is a foundational service of AWS that provides secure, resizable compute capacity in the cloud. It enables users to launch virtual servers—known as EC2 instances—on-demand, scale them up or down as needed, and pay only for what they use. EC2 eliminates the need to invest in hardware upfront, allowing organizations to deploy applications faster and more cost-effectively.
EC2 supports a wide variety of instance types, operating systems, and configurations, making it suitable for everything from small web applications to large-scale enterprise workloads. With features such as auto scaling, elastic load balancing, and integration with other AWS services, EC2 provides a flexible and powerful platform for running virtually any workload in the cloud.
Architecture
Key Components
Amazon Machine Image (AMI)
A pre-configured template that contains the software configuration (OS, application server, applications) required to launch an EC2 instance.
Instance Types
Different hardware configurations (CPU, memory, storage, networking) designed for various use cases, such as compute-optimized, memory-optimized, and GPU instances.
Elastic Block Store (EBS)
Persistent block storage volumes that can be attached to EC2 instances for data storage, backup, and recovery.
Key Capabilities
On-Demand Scalability
Launch or terminate instances as needed to match workload demand, ensuring optimal resource utilization and cost efficiency.
Secure Networking
Control inbound and outbound traffic to instances using security groups, network ACLs, and VPC configurations.
Flexible Pricing Options
Choose from On-Demand, Reserved, and Spot Instances to optimize costs based on your workload and usage patterns.
Common Use Cases
Implementation Example
# Terraform Example: Launch an EC2 Instance
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "example" {
ami = "ami-0c94855ba95c71c99" # Amazon Linux 2 AMI (for us-east-1)
instance_type = "t2.micro"
tags = {
Name = "ExampleEC2Instance"
}
}
This Terraform configuration launches a t2.micro EC2 instance in the us-east-1 region using the specified Amazon Linux 2 AMI. You can apply this configuration with terraform apply after initializing your AWS credentials.
Related Topics
Test Your Knowledge
Score 8/10 or higher to pass
You need to be logged in to take this quiz.
Login to Continue