Introduction

Overview

ℹ️ Information: Amazon EC2 provides scalable computing capacity in the AWS Cloud, allowing you to launch virtual servers on demand without investing in hardware upfront. This service forms the foundation for many cloud workloads, from web applications to enterprise databases.

Amazon Elastic Compute Cloud (EC2)

Amazon Elastic Compute Cloud (Amazon EC2) provides on-demand, scalable computing capacity within the Amazon Web Services (AWS) Cloud. Utilizing Amazon EC2 reduces hardware expenses, enabling faster application development and deployment. It empowers you to:

  • Launch as many or as few virtual servers as needed
  • Configure security and networking settings
  • Manage storage resources
  • Scale capacity up or down based on computing requirements

EC2 functions similarly to conventional servers but offers rapid initialization, robust resource scalability, and versatile flexibility. It supports a variety of workloads, including web hosting, applications, databases, authentication services, and other enterprise tasks.

The following diagram depicts a fundamental architecture of an Amazon EC2 instance deployed within an Amazon Virtual Private Cloud (VPC) within a specific Availability Zone in the Region. The EC2 instance’s security is governed by a security group, acting as a virtual firewall controlling inbound and outbound traffic. The instance employs a key pair for authentication, with an Amazon EBS volume providing persistent storage.

Amazon Elastic Compute Cloud (EC2)

Amazon EC2 Instance Types

ℹ️ Information: When provisioning EC2 resources, you must select an instance type that determines the hardware configuration of your virtual server.

Instance types define the following attributes:

  • Compute: CPU options include Intel, AMD, AWS Graviton (ARM-based), and GPU processors
  • Memory: RAM allocation varies by instance family
  • Storage: Options for local instance storage and network-attached EBS volumes
  • Network Performance: Bandwidth capabilities from moderate to 100+ Gbps

💡 Pro Tip: Choose the right instance family for your workload to optimize both performance and cost. For example, compute-optimized instances (C-family) are ideal for batch processing, memory-optimized instances (R-family) work best for database workloads, and general-purpose instances (T and M families) provide a balanced mix of resources.

Amazon Machine Images (AMI) and Storage Options

Amazon Machine Images (AMIs) serve as templates for EC2 instances, containing:

  • Operating system and its configuration
  • Application server and applications
  • Launch permissions defining which AWS accounts can use the AMI
  • Block device mapping that specifies the volumes to attach

AMI options include:

  • AWS-provided AMIs with common operating systems
  • AWS Marketplace AMIs with pre-configured software packages
  • Custom AMIs created from your existing EC2 instances

Storage options for EC2 include:

  • Amazon EBS volumes: Persistent, network-attached storage that exists independently of instance lifecycle
  • Instance store volumes: Temporary storage that’s physically attached to the host computer

⚠️ Warning: Data on instance store volumes is lost when the instance is stopped or terminated. Always use EBS volumes for data that needs to persist beyond the instance lifecycle.

Security and Access Management

🔒 Security Note: EC2 instances use multiple security mechanisms:

  • Key pairs: Public-private key pairs for secure SSH access to instances
  • Security groups: Virtual firewalls that control inbound and outbound traffic
  • Network ACLs: Stateless packet filtering at the subnet level
  • IAM roles: Secure method to grant permissions to applications running on EC2

Always store your private key files securely and never share them. Consider using AWS Systems Manager Session Manager for secure instance access without the need to open inbound ports or manage key pairs.

Key Features of Amazon EC2

ℹ️ Information: Amazon EC2 offers a comprehensive set of features for compute management:

Elastic Infrastructure

  • Scale capacity up or down automatically with Amazon EC2 Auto Scaling
  • Distribute traffic across instances using Elastic Load Balancing
  • Attach and detach resources dynamically as needed

Networking Capabilities

  • Virtual Private Clouds (VPCs): Logically isolated networks with complete control over the virtual environment
  • Elastic IP Addresses: Static IPv4 addresses for dynamic cloud computing
  • Placement Groups: Control instance placement strategy for performance or availability needs

💡 Pro Tip: To avoid charges for unused Elastic IP addresses, associate them with running instances or release them when not in use.

High Availability Options

  • Deploy across multiple Availability Zones for fault tolerance
  • Use Local Zones for low-latency compute near population centers
  • Leverage AWS Outposts for hybrid deployments in your own data center
  • Utilize Wavelength Zones for ultra-low latency applications at the edge of 5G networks

Resource Management

  • Tags: Metadata that you can create and assign to your Amazon EC2 resources for organization and billing
  • Resource Groups: Group related resources for easier management
  • AWS CloudFormation: Infrastructure as code for repeatable deployments

Monitoring and Management

  • Amazon CloudWatch: Monitor performance and set alarms
  • AWS CloudTrail: Track API calls for security analysis and operational troubleshooting
  • AWS Systems Manager: Manage EC2 instances at scale with operational insights