Back to home

Amazon EC2 Basics

Jul 10, 2026

Amazon EC2 Basics

Amazon EC2 is one of the first services people meet in AWS because it is the core of running virtual machines in the cloud. EC2 means Elastic Compute Cloud, and the name already tells the story. You rent compute when you need it, scale it when demand grows, and stop paying for it when you do not need it. This is why EC2 is usually the starting point for understanding how AWS works in practice.

If you are learning EC2 for AWS Certified Developer, the basic idea is simple. EC2 gives you a virtual server. On that server you can install software, run applications, host websites, and connect it with other AWS services. EC2 is usually discussed together with EBS, ELB, and Auto Scaling Group because those services fill the gaps around storage, load balancing, and scaling. So when people say “I launched an EC2 instance,” they are really talking about getting a machine in the cloud ready for work.

What EC2 Actually Gives You

EC2 is Infrastructure as a Service. That means AWS gives you the machine and the infrastructure, but you still control the operating system and the software running on top of it. You can choose Linux, Windows, or even Mac OS for some use cases. You also choose how much CPU, RAM, and storage you want. In other words, EC2 is not a fixed server. It is a configurable server that you shape based on the workload.

The main things you decide during EC2 setup are pretty practical. You choose the instance type, the storage option, the network settings, the security group, and the bootstrapping script if you want the machine to configure itself on launch. This is important because many beginner mistakes happen here. People launch an instance but forget the firewall rules, or they choose the wrong size, or they do not automate setup, and then the server is technically running but not useful.

EC2 Sizing and Configuration

EC2 sizing is about matching the machine to the job. If you need general purpose workloads like web servers or code repositories, a balanced instance type is usually enough. If the workload needs more CPU, then compute optimized instances make more sense. If the workload processes large data in memory, memory optimized instances are the better fit. If the workload reads and writes a lot of data on local storage, storage optimized instances are the right category.

This part matters because AWS does not expect you to use one server shape for everything. A machine that is good for a website may be bad for analytics. A machine that is good for cache may be bad for video processing. That is why EC2 instance families exist. The naming also follows a pattern, like m5.2xlarge, where the letter shows the family, the number shows the generation, and the size shows the capacity inside that family.

Storage, Network, and User Data

When you launch EC2, storage is another key decision. You can use network-attached storage like EBS or EFS, or you can use local hardware storage with instance store. EBS is the one most people use with EC2 because it is persistent and easy to attach to the instance. Instance store is faster in some cases, but it is temporary and tied to the life of the machine. That difference is easy to forget, but it matters a lot when you care about data surviving a stop or terminate action.

Network settings are also part of the EC2 setup. The public IP address, network card speed, and security group are all part of the machine’s behavior on the network. One useful feature here is EC2 User Data. This is a script that runs only once when the instance starts for the first time. It is used for bootstrapping, which means automatically installing packages, updating the machine, downloading files, or setting up your application without manual work. The script runs as root, so it can do the initial setup properly.

Security Groups Matter More Than People Think

Security groups are one of the most important EC2 topics. They act like a firewall for EC2 instances. They control inbound and outbound traffic, and they only contain rules. By default, all inbound traffic is blocked and all outbound traffic is allowed. That is a good default because it forces you to open only the ports you actually need.

What makes security groups useful is that they can reference an IP address or another security group. That means you can control access in a clean way when one EC2 instance needs to talk to another EC2 instance. Security groups are attached at the instance level, but they live outside the instance itself. So if traffic is blocked, the EC2 machine may not even see it. That is why security group issues often look like “timeout” problems instead of application errors.

Classic ports are also worth remembering. SSH uses port 22. HTTP uses port 80. HTTPS uses port 443. RDP uses port 3389 for Windows instances. FTP is port 21, and SFTP uses SSH on port 22. These ports come up again and again in AWS questions, especially when you troubleshoot connectivity or configure access to a server.

SSH and Getting Into the Instance

After the instance is running, the next thing is usually connecting to it. On Linux and Mac, SSH is the normal path. On Windows, people often use PuTTY or EC2 Instance Connect depending on the setup. The point is the same in every case: you want a secure way to control the remote machine from the command line.

This is where beginners often get stuck. If the instance is unreachable, first check the security group. If the connection says refused, the issue may be on the application side or the service may not be running. If the machine times out, the firewall or routing is usually the first place to look. That small difference between “timeout” and “connection refused” saves a lot of debugging time.

Why EC2 Basics Matter

EC2 is not just another AWS service. It is the base layer for understanding many other services around it. Once you understand how EC2 works, it becomes easier to understand load balancing, auto scaling, instance roles, storage choices, and deployment patterns. It also becomes easier to see why some workloads belong on EC2 and others belong on Lambda or ECS.

The real lesson is that EC2 is about control. You control the machine, the software, the ports, the storage, and the startup behavior. AWS gives you the cloud version of a server, but you still need to think like an operator. That is why the basics matter so much. If the foundation is weak, everything else built on top of it becomes harder.

Quick Summary

EC2 is the AWS service for renting virtual machines. You choose the operating system, compute power, memory, storage, networking, and security rules. User data helps you automate startup tasks, instance types help you match the machine to the workload, and security groups control who can talk to the instance. If you understand these basics well, the rest of the EC2 topics become much easier to follow.