Cloud Computing · Lesson 7

The Core Compute Services

EC2 AMIs, instance types, EBS and instance store volumes, EC2 pricing models, Lightsail, Elastic Beanstalk, containers with ECS and EKS, and serverless AWS Lambda.

  • ec2
  • ami
  • instance-types
  • ebs
  • pricing-models
  • lightsail
  • elastic-beanstalk
  • containers
  • lambda

Lesson purpose

Compute is where applications actually run. This lesson starts with Amazon EC2, the virtual-server service that mirrors a traditional data center, and walks through the four decisions behind every instance: the image, the instance type, the storage, and the pricing model. It then moves up the abstraction ladder — managed deployments with Lightsail and Elastic Beanstalk, containers with ECS and EKS, and serverless functions with Lambda — so students can match a workload to the right level of control and cost. It supports CLF-C02 objectives 3.1, 3.3, 4.1, and 4.2.

Learning objectives

  • Identify the elements needed to launch an EC2 instance: AMI, instance type, storage, and pricing model (plus key pair and network settings).
  • Describe the four AMI sources and the cost and trust differences among them.
  • Create a custom AMI and explain why it is useful.
  • Explain instance types, vCPUs, and instance families, and choose a family for a workload.
  • Distinguish dedicated instances from dedicated hosts.
  • Compare EBS volumes and instance store volumes.
  • Compare On-Demand, Reserved, and Spot pricing, and recognize Savings Plans.
  • Launch a simple web server using a user data script.
  • Compare Lightsail and Elastic Beanstalk as managed deployments.
  • Explain containers, ECS versus EKS, and serverless computing with Lambda.

1. EC2 and the virtual data center

Amazon Elastic Compute Cloud (EC2), launched in 2006, lets you provision instances — virtual servers — for the same workloads that once ran on physical servers, but with more resilience, faster scaling, and often lower cost.

Map each physical-server step to its EC2 equivalent:

On-premises step EC2 equivalent
Install an OS and software stack Choose an Amazon Machine Image (AMI)
Choose CPU, memory, and network hardware Choose an instance type
Buy and install drives Attach EBS (or instance store) volumes
Buy the server Choose a pricing model

2. Amazon Machine Images (AMIs)

An AMI is a software bundle — operating system and, optionally, an application stack — built from a template and available in one Region (it can be copied to others). When an instance launches, the AMI is copied to a new volume that becomes the instance’s boot drive.

AMIs range from clean operating systems (Amazon Linux, Ubuntu, Red Hat Enterprise Linux, Windows Server) to fully loaded stacks (OpenVPN, TensorFlow, a Juniper firewall).

The four AMI collections

  • Quick Start — the most popular AMIs, selected by AWS; many are Free Tier eligible. Linux options are often long-term support (LTS) releases, which receive updates for years, so production servers need rebuilding less often. Each listing shows the OS and release, root device type (EBS), AMI ID, and architecture (64-bit x86 or 64-bit Arm).
  • My AMIs — custom images you created.
  • AWS Marketplace — vendor products (SAP, Oracle, NVIDIA, and others) packaged as ready-to-run AMIs. The price shows a software charge plus the EC2 infrastructure charge. Many offer free trials, pay-as-you-go, or bring your own license (BYOL).
  • Community AMIs — shared by vendors and individual users. Some are vendor-supported (for example, Canonical); others are provided as is. You are responsible for the security and reliability of any community image you launch.

Licensing: open-source systems such as Amazon Linux and Ubuntu carry no license charge. Windows Server and RHEL include license costs, billed through your AWS account.

Custom AMIs

You can turn a configured instance into an AMI: take a snapshot of its EBS volume and create an image from it (the console’s Create image action does both). Why? If you spent a week configuring the perfect application server, an AMI lets you launch identical copies whenever demand grows, instead of repeating the work.

Book Exercise 7.1: start Launch instance, choose Browse more AMIs, and compare Quick Start, Marketplace (search for an example product and note pay-as-you-go vs. BYOL), and Community listings. Cancel without launching.

3. Instance types and families

An instance type describes the hardware an instance gets: virtual CPUs (vCPUs), memory, network performance, and sometimes local storage. Examples from the book: t2.micro has 1 vCPU and 1 GiB of memory; c5d.18xlarge has 72 vCPUs and 144 GiB.

Read an instance type name like this: c5d.18xlarge → family c (compute optimized), generation 5, attribute d (local NVMe instance storage), size 18xlarge.

A vCPU is AWS’s unit of compute; it does not map exactly to a physical core, so compare instance types by testing, not by vCPU count alone.

More resources usually mean better performance, but choosing the right family often matters more — and can mean fewer vCPUs and lower cost.

Family Optimized for Example types Example workloads
General purpose Balanced CPU, memory, network M, T, Mac Web servers, small databases, dev/test
Compute optimized High CPU performance C Batch processing, gaming servers, scientific modeling
Memory optimized Large data sets in memory R, X, z1d, High Memory In-memory databases and caches, big-data analytics
Accelerated computing GPUs and custom chips P, G, Inf, Trn, F, DL Machine learning, graphics, video processing
Storage optimized Fast local storage throughput I, D, H Data warehousing, distributed file systems
HPC optimized High-performance computing Hpc Large tightly coupled simulations

Instance families change often; always check the current list at aws.amazon.com/ec2/instance-types.

T types are “burstable”: they earn CPU credits while idle and spend them during bursts, which suits workloads that are usually quiet.

Dedicated instances and dedicated hosts

When regulations or company policy require physical isolation from other customers:

  • Dedicated instance — runs on hardware reserved for your account; AWS decides placement.
  • Dedicated host — an entire physical server allocated to you, with visibility and control over how instances are placed on it. Useful for bring-your-own-license software licensed per socket or core.

Both cost extra and can be bought on-demand or reserved.

4. Instance storage: EBS vs. instance store

Instance storage is virtual — a slice of much larger physical storage.

Amazon Elastic Block Store (EBS)

EBS volumes live on storage connected to the instance over a very low-latency network, not cabled to the host.

  • Persistent — data survives stops, restarts, and host failures. The volume’s lifetime is independent of the instance (a root volume is deleted on termination only if “delete on termination” is set, which is the default for root volumes).
  • Encryptable with KMS keys (Lesson 5).
  • Flexible — detach and attach to another instance in the same Availability Zone, snapshot, and convert to AMIs.

Instance store volumes

Instance store volumes are physical disks attached directly to the host server.

  • Very fast reads and writes.
  • Ephemeral — data is lost when the instance stops, terminates, or the underlying hardware fails (a reboot keeps it).
  • Not movable to another instance.

Correction to the book: the book says instance store volumes cannot be encrypted. On current (Nitro-based) instance types, AWS encrypts NVMe instance store data at rest automatically.

Use instance store for temporary data — caches, buffers, scratch space, fast-moving data streams — and EBS for anything that must be kept.

5. EC2 pricing models

Model How it works Best for Watch out for
On-Demand Pay for compute time while the instance runs (per second for Linux, with a 60-second minimum); no commitment Short-term, spiky, or unpredictable workloads that can’t be interrupted — for example, a one-day sale Most expensive for always-on workloads
Reserved Instances Commit to a 1- or 3-year term for a specific instance type and Region in exchange for a large discount Steady workloads that run 24/7 Paying for the reservation even if unused
Spot Instances Use spare AWS capacity at up to 90 percent off On-Demand Fault-tolerant, flexible jobs: batch, big data, CI/CD, test and dev AWS can reclaim the instance with a two-minute warning

Reserved Instance details

  • A reservation is not a server. It is a billing discount that applies automatically to running instances that match its attributes (instance type and Region).
  • Terms are 1 year or 3 years. You can buy unused reservations from other customers in the Reserved Instance Marketplace, sometimes with shorter remaining terms.
  • Payment options: All Upfront (largest discount), Partial Upfront, No Upfront (smallest discount).

Modern note: Savings Plans are AWS’s more flexible commitment option. You commit to a dollar amount of compute per hour for 1 or 3 years, and the discount applies across instance families, sizes, Regions, and even Fargate and Lambda (Compute Savings Plans). Savings Plans appear on the CLF-C02 exam alongside Reserved Instances.

Spot details

Spot capacity can be requested individually or through a Spot Fleet, which specifies target capacity and price across many instance types, and it can be built into larger automated deployments. Design Spot workloads to checkpoint their work and tolerate interruptions.

Check for understanding: A payroll batch job runs every night, can restart if interrupted, and must be as cheap as possible. (Spot.) A company database runs 24/7 for the next three years. (Reserved Instance or Savings Plan.) A marketing site needs extra servers for one weekend. (On-Demand.)

6. Launching a web server (book Exercise 7.2)

Walk through the launch wizard and name each decision as it appears:

  1. Launch instance → choose an Amazon Linux AMI.
  2. Instance type: keep the Free Tier-eligible default (t2.micro or t3.micro, depending on Region).
  3. Key pair: create or select one (Lesson 5), even if you won’t SSH in.
  4. Network settings: allow HTTP traffic from the internet so the web page can be reached.
  5. Storage: keep the default EBS root volume.
  6. Advanced details → User data: paste a startup script that runs once, as root, at first boot.
#!/bin/bash
yum install -y httpd
systemctl start httpd
systemctl enable httpd
  • #!/bin/bash (the “shebang”) tells Linux to run the lines that follow with the Bash shell.
  • yum install -y httpd installs the Apache web server; -y answers “yes” automatically. (On Amazon Linux 2023, yum still works and points to the newer dnf package manager.)
  • systemctl start httpd starts Apache now.
  • systemctl enable httpd makes Apache start again automatically after a reboot (added here; the book’s script omits it).
  1. Launch, then open Instances and wait for Running and passing status checks.
  2. Copy the instance’s Public IPv4 address, paste it into a browser using http://, and confirm the Apache test page appears. The browser may warn that the connection is not secure because no TLS certificate is configured.
  3. Clean up: Instance state → Terminate instance so billing stops.

Cost caution: Free Tier terms depend on when the AWS account was created and have changed over time, so check the account’s Free Tier or credit status before launching anything, and always terminate lab instances.

7. Managed services and managed deployments

A managed service runs part of the stack for you. Example: Amazon RDS (Lesson 9) — you pick the database engine and settings and get an endpoint; AWS handles the database server, patching, and replication. Managed services may cost more but save administration time.

A managed deployment goes further: AWS handles the whole stack, and you supply only code or content.

Amazon Lightsail

  • The simplest on-ramp to AWS: choose a blueprint and a flat monthly price plan, and Lightsail provisions the compute, storage, database, and networking.
  • Blueprints include operating systems (Amazon Linux, Ubuntu, Debian, FreeBSD, openSUSE, CentOS) and applications (WordPress, Magento, LAMP, MEAN, Node.js, Ghost, GitLab, Django, Drupal, Joomla, Plesk, cPanel, and more).
  • Plans start at a few dollars per month; pricing changes, so check the Lightsail pricing page.
  • Built on EC2, so a Lightsail workload can later be exported to regular EC2 for more control.

Stack vocabulary from the book:

  • LAMP — Linux, Apache, MySQL or MariaDB, PHP (or Python).
  • MEAN — MongoDB, Express.js, Angular, Node.js (all JavaScript).

AWS Elastic Beanstalk

  • Choose a platform (.NET, Docker, Go, Java, Node.js, PHP, Python, Ruby, Tomcat) and upload your code. Beanstalk provisions and manages the EC2 instances, load balancing, Auto Scaling, and monitoring.
  • There is no extra charge for Beanstalk itself; you pay for the resources it creates, and cost varies with demand as the environment scales up and down.
  • You keep access to the underlying resources if you need to adjust them.
Lightsail Elastic Beanstalk
You provide Blueprint choice and plan Application code
Pricing Flat monthly plan Pay for resources used; varies with demand
Scaling Choose a bigger plan Automatic, based on demand
Best for Simple websites, small apps, beginners Web applications that must scale without managing servers

8. Containers: ECS and EKS

Each virtual machine needs its own full operating system, kernel, and drivers, so running many VMs on one host duplicates a lot. Containers (such as Docker) share the host’s operating system kernel and can share common image layers, so they start quickly, use fewer resources, and pack densely onto hardware.

You could install Docker on EC2 yourself, but coordinating many containers is complex. AWS orchestration services manage it:

  • Amazon Elastic Container Service (ECS) — AWS’s own container orchestrator; simpler and tightly integrated with AWS.
  • Amazon Elastic Kubernetes Service (EKS) — managed Kubernetes, the popular open-source orchestrator (the book uses an older name, “Elastic Container Service for Kubernetes”). Good for teams already using Kubernetes or needing portability.

“Different paths to the same place”: both run and manage containers on AWS.

Modern note: containers in ECS or EKS can run on EC2 instances you manage or on AWS Fargate, a serverless option where AWS manages the servers and you pay for the container’s CPU and memory.

9. Serverless: AWS Lambda

Serverless computing removes server management entirely. AWS Lambda runs a function only when an event triggers it:

  • a request from a mobile or web app (often through API Gateway)
  • a change to a resource, such as a new object uploaded to an S3 bucket
  • a log alert, schedule, or message

You choose a runtime (Node.js, Python, Java, .NET, and others) and upload the code or a container image.

Key facts:

  • No trigger, no charge — you pay per request and for execution time.
  • Scales automatically — a thousand simultaneous events can run a thousand copies.
  • Short-lived — the maximum run time is 15 minutes.

Lambda vs. Beanstalk: both take your code, but a Beanstalk application runs continuously on instances, while a Lambda function runs only when triggered.

The abstraction ladder

Service You manage AWS manages Billing
EC2 OS, patches, apps, scaling Hardware, virtualization Per instance time
Lightsail App configuration Nearly the whole stack Flat monthly
Elastic Beanstalk Code Servers, scaling, load balancing Resources used
ECS / EKS (with Fargate) Container images Orchestration (and servers with Fargate) Resources used
Lambda Function code Everything else Per request and duration

Classroom application

  • Lab: Complete Exercise 7.2 in pairs. One student reads each wizard setting aloud and explains the decision; the other clicks. Confirm the “It works!” page, then terminate.
  • AMI hunt: Find one Quick Start, one Marketplace, and one Community AMI for the same OS. Compare cost, publisher, and trust.
  • Instance-type matching: Give scenarios — a busy in-memory cache, video rendering, a small blog, a data warehouse on local disks — and have students choose a family.
  • Pricing debate: For each workload, choose On-Demand, Reserved/Savings Plan, or Spot and defend the choice:
    • a university registration site that is busy for two weeks each semester
    • a three-year line-of-business database
    • nightly image thumbnail processing that can restart
  • Compute ladder: A student club wants a WordPress site (Lightsail), a developer has a Python web app (Beanstalk), a team runs microservices in Docker (ECS/Fargate), and a photo site needs thumbnails whenever an image is uploaded (Lambda).

Common misconceptions

  • “Buying a Reserved Instance creates a server.” It is a billing discount applied to matching running instances.
  • “Spot means bidding against other customers.” You pay the current Spot price; the risk is interruption with two minutes’ notice.
  • “Stopping an instance keeps instance store data.” Instance store data is lost on stop or termination; only EBS persists.
  • “More vCPUs always means faster.” The right instance family often matters more than size.
  • “Community AMIs are vetted by AWS.” You are responsible for verifying them.
  • “Serverless means there are no servers.” There are servers; AWS manages them, and you never see them.
  • “Lambda can run long jobs.” Functions time out after 15 minutes; long jobs belong on EC2, containers, or batch services.
  • “Containers are small VMs.” Containers share the host kernel; VMs each run a full operating system.

Lesson summary

An EC2 instance is defined by its AMI, instance type, storage, and pricing model. AMIs come from Quick Start, My AMIs, AWS Marketplace, and Community collections, and a configured instance can be saved as a custom AMI for identical copies. Instance types set vCPUs, memory, and network performance, and choosing the right family — general purpose, compute, memory, accelerated, storage, or HPC optimized — matters as much as size; dedicated instances and hosts provide physical isolation. EBS volumes are persistent, encryptable, and flexible, while instance store volumes are faster but temporary. On-Demand suits short, uninterruptible work; Reserved Instances and Savings Plans cut the cost of steady workloads; Spot offers the deepest discounts for interruptible jobs. User data scripts configure instances automatically at launch. Lightsail offers flat-priced blueprints, and Elastic Beanstalk deploys code that scales automatically. Containers share the host kernel and are orchestrated by ECS or EKS, optionally on Fargate, and Lambda runs short, event-triggered functions that scale automatically and cost nothing when idle.