← Back to Home

Amazon EC2

AWS CLF-C02 — Domain 3: Cloud Technology & Services

EC2 Overview

Key Point:

EC2 is IaaS. You manage the OS and everything above it. AWS manages the physical hardware, hypervisor, and networking infrastructure beneath.

EC2 Instance Types

Naming Convention

Example: m5.2xlarge

FamilyOptimized ForExample TypesUse Cases
General PurposeBalance of compute, memory, networkingt2, t3, m5, m6iWeb servers, code repositories, small/mid databases, dev environments
Compute OptimizedHigh-performance processorsc5, c6i, c6gBatch processing, media transcoding, HPC, ML inference, gaming servers
Memory OptimizedLarge datasets in memoryr5, r6i, x1, x2idnIn-memory databases (Redis, Memcached), real-time big data analytics
Storage OptimizedHigh sequential read/write to local storagei3, i3en, d2, h1Data warehousing, distributed file systems, high-frequency OLTP
Accelerated ComputingHardware accelerators / GPUsp3, p4d, g4dn, g5Machine learning training, graphics rendering, video processing
Exam Tip:

Remember the first letter: T/M = General, C = Compute, R/X = Memory (RAM), I/D = Storage (I/O), P/G = Accelerated (GPU). The exam won't ask for specific instance specs but will test which family fits a use case.

Security Groups

Security Groups act as a virtual firewall for your EC2 instances to control inbound and outbound traffic.

Key Characteristics

FeatureSecurity GroupsNetwork ACLs (for comparison)
LevelInstance levelSubnet level
RulesAllow onlyAllow and Deny
StateStatefulStateless
EvaluationAll rules evaluatedRules processed in order
Exam Tip:

If an application on EC2 is not reachable, the first thing to check is the Security Group rules. A "timeout" error usually means a security group issue. A "connection refused" error means the application itself has an issue.

EC2 Purchasing Options

OptionCommitmentDiscountBest For
On-DemandNone — pay by the second (Linux) or hour (Windows)0% (full price)Short-term, unpredictable workloads; no upfront payment
Reserved Instances (RI)1 year or 3 yearsUp to 72%Steady-state usage (databases, web servers that run 24/7)
Convertible Reserved1 year or 3 yearsUp to 66%Long-term but may need to change instance type/family/OS
Savings Plans1 year or 3 years ($/hr commitment)Up to 72%Flexible across instance sizes, OS, tenancy; commit to $/hr spend
Spot InstancesNoneUp to 90%Fault-tolerant, flexible workloads (batch, data analysis, image processing)
Dedicated HostsNone or ReservedVariesRegulatory/compliance needs, bring your own server-bound licenses (BYOL)
Dedicated InstancesNoneVariesInstances running on hardware dedicated to you (no control over placement)
Capacity ReservationsNone — reserve capacity in a specific AZ0% (On-Demand price)Guarantee capacity is available when you need it
Key Point:

Spot Instances can be interrupted by AWS with a 2-minute warning. Never use Spot for critical or stateful workloads. Dedicated Hosts give you access to the physical server and let you use per-socket or per-core licenses.

Exam Tip:

"Which option provides the highest discount?" → Spot Instances (up to 90%). "Which option is best for compliance with server-bound software licenses?" → Dedicated Hosts. "Which option is best for steady-state workloads?" → Reserved Instances or Savings Plans.

Connecting to EC2 Instances

SSH (Secure Shell)

EC2 Instance Connect

Other Connection Methods

Exam Tip:

"How to connect to an EC2 instance without opening port 22?" → AWS Systems Manager Session Manager. This is more secure because no inbound ports need to be open.

EC2 User Data (Bootstrap Scripts)

Key Point:

User data scripts run as root and only execute on the first boot of the instance. They are commonly used to install web servers, pull code from repositories, or configure the environment.

EC2 Key Pairs

Exam Tip:

If you lose your private key, you cannot SSH into the instance using that key pair. You would need to use EC2 Instance Connect, Session Manager, or create a new key pair and update the instance.