# AWS EC2

> Amazon Elastic Compute Cloud (EC2) is a web service offered by Amazon Web Services (AWS) that provides resizable and scalable compute capacity in the cloud.

- Source: https://www.itwonderlab.com/aws-ec2/
- Published: 2023-09-05
- Updated: 2026-10-05
- Author: Javier Ruiz Jiménez (https://www.javierruizjimenez.com/)
- Site: IT Wonder Lab (https://www.itwonderlab.com/)

---

## Amazon Elastic Compute Cloud

EC2 is a web service offered by Amazon Web Services (AWS) that provides resizable and scalable computing capacity in the cloud. In simple terms, AWS EC2 allows you to launch and manage virtual machines, known as instances, in the AWS cloud.

AWS EC2 is widely used for a variety of applications, including web hosting, data processing, machine learning, and more. It forms the foundation for many cloud-based solutions and allows businesses to rapidly deploy and manage virtual machines in the cloud without the need for physical hardware.

### Scale Computing Resources

EC2 instances can be easily scaled up or down based on your workload demands. This scalability ensures that you pay only for the compute capacity you use.

### Instance Types

AWS offers a variety of instance types optimized for different workloads, including general-purpose, compute-optimized, memory-optimized, and GPU instances.

AWS has over 700 instance types or combinations of CPU, memory, storage, networking, and specialized chips, offered as virtual or bare metal running Linux, Windows, or Mac operating systems.

#### Customize Instances

Choosing the right instance can be challenging: cloud infrastructure and [IaC](https://www.itwonderlab.com/iac/) make it possible to test different configurations and to change them over time, as requirements and usage become better known.

Check all the available options on the [AWS Instance Type Details](https://aws.amazon.com/ec2/instance-types/) page.

#### Processor Architectures

Instances are available in multiple processor architectures:

-   x86 (64-bit Intel Xeon and AMD EPYC),
-   ARM (64-bit AWS Graviton processors),
-   Apple silicon (64-bit M1, M2 and later Mac instances).

#### Specialized Chips

Additionally, instances can have specialized chips like

-   AMD and NVIDIA GPUs,
-   AWS Inferentia2 accelerators for deep learning (DL),
-   AWS Trainium chips for deep learning training,
-   AMD Xilinx FPGAs for custom hardware acceleration.

### Secure and Manage Instances

AWS provides features for managing and securing instances, including [security groups](https://www.itwonderlab.com/aws-security-groups/), [key pairs](https://www.itwonderlab.com/public-key-authentication/), and [Identity and Access Management (IAM)](https://www.itwonderlab.com/aws-iam/) roles and policies.

### Load Balancing and Auto Scaling

AWS services like [Elastic Load Balancing (ELB)](https://www.itwonderlab.com/aws-elastic-load-balancing/) and [Auto Scaling](https://www.itwonderlab.com/aws-auto-scaling/) in conjunction with EC2 provide high availability and efficient scaling of applications.

Auto Scaling automatically adjusts the number of instances running an application based on real-time demand. **Scaling policies** use metrics such as CPU utilization, network traffic or custom application metrics that are constantly monitored: when the usage exceeds a threshold, AWS adds new instances and shares the load between them. When the load decreases, the additional instances are removed.

### Data Storage Options

AWS offers various storage options, including Amazon [Elastic Block Store (EBS)](https://www.itwonderlab.com/aws-ebs/) for block storage and [Amazon S3](https://www.itwonderlab.com/aws-s3/) for object storage, which can be attached to your EC2 instances.

### Networking and VPC

You can configure [Virtual Private Cloud (VPC)](https://www.itwonderlab.com/aws-vpc/) networks and [subnets](https://www.itwonderlab.com/aws-subnets/) to isolate and control the networking environment for the EC2 instances.

### AMI Management

EC2 instances are launched from [Amazon Machine Images (AMIs)](https://www.itwonderlab.com/aws-ami/), allowing to create, customize, and share pre-configured system images.

### Monitoring and Management

AWS provides tools like [Amazon CloudWatch](https://www.itwonderlab.com/aws-cloudwatch/) for monitoring and [AWS Systems Manager](https://www.itwonderlab.com/aws-systems-manager/) for managing EC2 instances at scale.

### Instance Lifecycle

Most instances start in seconds in any [AWS Region](https://www.itwonderlab.com/aws-regions-availability-zones/). They can also be hibernated, stopped, terminated, backed up or cloned by taking a point-in-time snapshot of the storage, with the instance running or stopped.

### Purchasing Options

- **On-Demand**: pay per second (Linux) or per hour, with no commitment.
- **Savings Plans and Reserved Instances**: a discount in exchange for a commitment of one or three years.
- **Spot Instances**: unused capacity at a large discount that AWS can reclaim with a two-minute notice, suitable for fault-tolerant workloads.

### With Terraform

EC2 instances are created with the resource `aws_instance`, or with a launch template and an [Auto Scaling group](https://www.itwonderlab.com/aws-auto-scaling/) for groups of instances. The AMI can be found with the `aws_ami` data source.

See tutorials:

-   [AWS with Terraform: The Essential Guide (12/21) – AWS EC2 Instances](https://www.itwonderlab.com/aws-terraform-tutorial-aws-ec2/)
-   [AWS with Terraform: The Essential Guide (15/21) – AWS Auto Scaling](https://www.itwonderlab.com/aws-terraform-tutorial-aws-auto-scaling/)
