Sub topic 1
What EC2 Is and What You Are Responsible For
Amazon Elastic Compute Cloud (EC2) provides resizable virtual servers called instances. You choose the operating system, hardware size, network location, and storage. AWS runs the underlying facilities and physical infrastructure. You manage the guest operating system, installed software, data, access controls, and security configuration.
Prerequisites
This chapter assumes basic Linux command-line skills, IP addresses, CIDR blocks, ports, SSH, and AWS identity and access management (IAM).
Regions and Availability Zones
A Region is a separate geographic area, such as us-east-1. An Availability Zone (AZ) is an isolated data-center location inside a Region. An instance runs in one subnet, and each subnet belongs to one AZ.
Choose a Region near users or other services to reduce network delay. Also consider service availability, regulations, and price. For resilient systems, place instances in multiple AZs.
flowchart TD
R[Region: us-east-1] --> A[Availability Zone A]
R --> B[Availability Zone B]
A --> S1[Subnet 1]
B --> S2[Subnet 2]
S1 --> I1[EC2 instance]
S2 --> I2[EC2 instance]Choosing an AMI
An Amazon Machine Image (AMI) is a template for an instance. It includes an operating system and may include software and configuration. Select an AMI that matches your operating system, CPU architecture, Region, and security requirements. Official or trusted publisher images reduce supply-chain risk. Keep the image patched after launch.
Instance Types and Families
An instance type defines virtual CPUs, memory, network capacity, and sometimes local storage. General-purpose types, such as t3, suit many small workloads. Compute-optimized types suit CPU-heavy work. Memory-optimized types suit databases and in-memory processing. GPU types suit machine learning and graphics.
Start with a small type, measure CPU, memory, network, and disk behavior, then resize when needed.
| Choice | Typical fit |
|---|---|
| General purpose | Web servers and development |
| Compute optimized | CPU-heavy processing |
| Memory optimized | Large in-memory databases |
VPCs, Subnets, and IP Addresses
A Virtual Private Cloud (VPC) is your isolated virtual network. A subnet is an IP range inside one AZ. A public subnet has a route to an internet gateway; a private subnet does not directly accept internet traffic.
An instance usually receives a private IPv4 address. A public IPv4 address allows internet communication but may change after a stop and start. Use an Elastic IP when a stable public address is required.
Controlling Traffic with Security Groups
A security group is a stateful virtual firewall attached to an instance. Inbound traffic is denied by default. Add only the required ports and source ranges, such as SSH port 22 from an administrator’s network, not from everywhere.
Exercise
Why can two instances in the same VPC still be unable to connect?
Show answer
Their security groups may not allow the required protocol and port from the other instance's private IP or security group.