Amazon EC2 (Elastic Compute Cloud) is the Amazon Web Services product that lets you launch virtual machines, called instances, on demand. You choose the operating system image, CPU and memory size, storage and network settings, and you pay for the time the instance runs.
Why it matters
EC2 is one of the most common places to host websites, APIs and databases on AWS. Because you control the whole operating system, it suits software that cannot run in a managed or serverless platform. The trade-off is responsibility: you patch the OS, secure the instance and plan for failure, since a single instance can be stopped or replaced.
Example
An instance is launched from an Amazon Machine Image (AMI), placed in a subnet, and protected by a security group:
aws ec2 run-instances \
--image-id ami-0123456789abcdef0 \
--instance-type t3.small \
--key-name my-key \
--security-group-ids sg-0abc1234
The instance gets a private IP, and a public IP only if the subnet assigns one.
Common mistakes
- Running one instance in one availability zone and calling it highly available.
- Leaving a security group open to the whole internet on SSH port 22.
- Forgetting that a public IP changes after a stop and start unless you attach an Elastic IP.
- Ignoring stopped instances, whose attached storage volumes still cost money.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.