Compute

AWS EC2

Amazon Elastic Compute Cloud (EC2) provides resizable virtual servers in the cloud. Launch instances with your choice of OS, networking, and storage in seconds, and scale capacity up or down as your computing requirements change.

What is EC2? (Simple Explanation)

Think of EC2 like renting a computer in the cloud. Instead of buying a physical server and putting it in a rack, you click a button and get a virtual computer running in seconds. You can install anything on it — websites, databases, games, machine learning models.

When Would You Use EC2?

  • Web application hosting
  • Batch processing & HPC
  • Disaster recovery
  • Development & test environments
  • Microservices architecture

Who Uses EC2?

From startups to enterprises, EC2 powers:

StartupsMid-size CompaniesLarge EnterprisesGovernmentNonprofits

What Makes EC2 Powerful

Auto Scaling groups for demand-based scaling
Multiple instance types (general, compute, memory, storage optimized)
Elastic IP addresses for static public endpoints
Placement groups for low-latency workloads
Instance metadata service (IMDSv2) for secure credential delivery

EC2 Pricing & Free Tier

Free Tier: 750 hours/month of t2.micro or t3.micro (12 months). Pay-as-you-go thereafter — from ~$0.005/hour for nano instances.

EC2 Best Practices

  1. 1Use IMDSv2 to prevent SSRF credential theft
  2. 2Right-size instances — most workloads use <30% of allocated CPU
  3. 3Use Spot or Reserved Instances for 50-72% cost savings
  4. 4Enable termination protection on production instances
  5. 5Tag all instances for cost allocation and governance

Getting Started with EC2 in 5 Minutes

  1. 1Open the AWS Console and navigate to EC2
  2. 2Click "Launch" or "Create" and choose your configuration (OS, instance type, region)
  3. 3Configure security settings — attach an IAM role and select or create a security group
  4. 4Review your settings and click "Launch" — your resource is ready in minutes

EC2 CLI Quick Reference

3 production-ready commands. Full CLI Library (225+ services) →

aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,InstanceType,State.Name,Tags[?Key==`Name`].Value|[0]]' --output tableList all EC2 instances with type, state, and Name tag
aws ec2 run-instances --image-id ami-0abcdef1234567890 --instance-type t3.micro --key-name my-key --security-group-ids sg-xxx --subnet-id subnet-xxx --count 1Launch a new EC2 instance
aws ec2 describe-security-groups --group-ids sg-xxx --query 'SecurityGroups[*].{ID:GroupId,Name:GroupName,Inbound:IpPermissions,Outbound:IpPermissionsEgress}'Inspect security group inbound/outbound rules

Pros & Cons of EC2

Pros

  • Auto Scaling groups for demand-based scaling
  • Multiple instance types (general, compute, memory, storage optimized)
  • Elastic IP addresses for static public endpoints
  • Placement groups for low-latency workloads
  • Instance metadata service (IMDSv2) for secure credential delivery

Cons

  • Costs can escalate quickly without right-sizing and Reserved Instances
  • Requires understanding of instance types, AMIs, and networking for optimal use
  • Not truly serverless (except Lambda/Fargate) — you still manage OS, patches, scaling config

EC2 vs Alternatives

EC2 vs Lambda
Choose EC2 when

Choose EC2 when you need full OS control, long-running processes (>15 min), custom AMIs, GPU compute, or consistent high throughput that would be more expensive on Lambda.

Choose Lambda when

Choose Lambda when you have event-driven, short-running code (<15 min), variable traffic with idle periods, or want zero server management — you pay only for execution time.

EC2 vs Fargate
Choose EC2 when

Choose EC2 when you need GPU instances, custom AMIs, placement groups, or spot capacity optimization at the instance level.

Choose Fargate when

Choose Fargate when you want to run containers without managing EC2 instances — no patching, no cluster scaling, no OS-level security updates.

Services That Work with EC2

EC2 is rarely used alone. It is typically combined with:

Compliance & Security

How AWS EC2 fits into major compliance standards. Browse all 41 frameworks →

Frequently Asked Questions About EC2

What is AWS EC2?

Amazon Elastic Compute Cloud (EC2) provides resizable virtual servers in the cloud. Launch instances with your choice of OS, networking, and storage in seconds, and scale capacity up or down as your computing requirements change.

What is EC2 used for?

EC2 is commonly used for: Web application hosting; Batch processing & HPC; Disaster recovery; Development & test environments; Microservices architecture. It's a core service in the compute category of AWS.

Is EC2 free?

Free Tier: 750 hours/month of t2.micro or t3.micro (12 months). Pay-as-you-go thereafter — from ~$0.005/hour for nano instances.

What are the key features of EC2?

EC2's most important capabilities include: Auto Scaling groups for demand-based scaling. Multiple instance types (general, compute, memory, storage optimized). Elastic IP addresses for static public endpoints. Placement groups for low-latency workloads. Instance metadata service (IMDSv2) for secure credential delivery. Each of these is designed to help teams web application hosting.

How does EC2 compare to alternatives?

EC2 competes with both AWS-native alternatives (EBS, ELB, Auto Scaling) and third-party equivalents. The right choice depends on your specific requirements for scalability, cost, and operational overhead. See the comparisons section below for detailed guidance.

Which compliance frameworks apply to EC2?

CIS AWS v3.0: EC2 configuration is audited by CIS Benchmarks v1.5–v3.0 for secure cloud defaults. NIST 800-53: EC2 access controls, encryption, and audit logging map to NIST 800-53 AC, SC, and AU control families. PCI DSS 4.0: EC2 encryption, access control, and logging support PCI DSS for cardholder data environments. SOC 2: EC2 security, availability, and confidentiality controls evaluated under SOC 2 Trust Services Criteria. ISO 27001: EC2 configuration and monitoring controls map to ISO 27001 Annex A information security management.

People also search for

AWS EC2 tutorialEC2 getting startedEC2 best practicesEC2 pricingEC2 free tierwhat is EC2EC2 vsEC2 documentationEC2 cheat sheetEC2 instance typesEC2 vs LambdaEC2 vs ECSEC2 auto scalingEC2 spot instancesEC2 reserved instances pricing

Was this page helpful?

Ready to secure your EC2 configuration?

Pavora continuously monitors your AWS EC2 for misconfigurations, compliance violations, and security risks.