Unit 1: Introduction to Cloud Computing and AWS; Amazon EC2 and Amazon EBS

CSC301 — Introduction To Cloud Computing 8 min read

I. Orientation: The Cloud Computing Model

Cloud computing (popularised from the mid-2000s, AWS launched 2006) delivers IT resources on demand over the internet with pay-as-you-go pricing, replacing owned hardware with rented, elastic capacity.

  • On-demand self-service: users provision compute, storage and networking without human intervention from the provider.
  • Broad network access: resources reached over standard protocols (HTTPS, SSH) from any device.
  • Resource pooling: physical hardware is multi-tenant; capacity is shared across customers via virtualization.
  • Elasticity: capacity scales out and in to match load, often automatically.
  • Measured service: usage is metered (instance-hours, GB-months) and billed accordingly.
  • Service models: IaaS (raw compute, e.g. EC2), PaaS (managed runtime), SaaS (ready applications).

II. Cloud Computing Foundations

A. Cloud Computing and Virtualization

Virtualization is the enabling technology that lets one physical server host many isolated virtual machines.

  • Hypervisor: software layer (Type 1 bare-metal, e.g. Xen/Nitro; Type 2 hosted) that allocates CPU, memory and I/O to guest VMs.
  • Isolation: each VM runs its own OS; a crash or breach in one does not touch neighbours.
  • Hardware abstraction: the guest sees virtual CPUs and virtual NICs mapped onto shared physical hardware, enabling overcommit and consolidation.
  • AWS Nitro System: offloads virtualization to dedicated hardware cards, giving near-bare-metal performance for EC2.

B. Cloud Computing Architecture

Cloud architecture splits into the parts the user controls and the parts the provider runs.

  • Front end: client devices and interfaces (console, CLI, SDK) that submit requests.
  • Back end: provider-managed servers, storage, virtualization and networking.
  • Deployment models: public (shared, e.g. AWS), private (single-tenant), hybrid (connected mix), community.
  • Decoupling: well-architected systems separate tiers (web, application, data) so each scales independently.

C. Cloud computing optimization

Optimization balances cost, performance and reliability.

  • Cost optimization: right-size instances, use reserved/spot pricing, delete idle resources, tier storage.
  • Performance efficiency: match instance family to workload (compute-, memory-, storage-optimized).
  • Elastic matching: scale with demand so you neither over-provision (waste) nor under-provision (throttle).
  • The AWS Well-Architected Framework pillars: operational excellence, security, reliability, performance efficiency, cost optimization, sustainability.

III. The AWS Platform

A. AWS Platform Architecture

AWS organises its global infrastructure into a hierarchy that underpins availability and latency.

  • Regions: geographically separate areas (e.g. us-east-1); you choose one for data residency and proximity.
  • Availability Zones (AZs): one or more discrete data centres within a Region, isolated for fault tolerance; spreading resources across AZs survives a single-site failure.
  • Edge locations: points of presence for CloudFront CDN and Route 53, caching content near users.
  • Shared Responsibility Model: AWS secures the cloud (hardware, facilities, hypervisor); the customer secures in the cloud (OS patches, data, IAM, firewall rules).

B. AWS Reliability and Compliance

Reliability is engineered through redundancy; compliance is proven through audited standards.

  • Multi-AZ design: replicate across AZs so an AZ outage does not take down the application.
  • SLAs: published uptime commitments (e.g. EC2 Region-level ~99.99%).
  • Compliance programs: ISO 27001, SOC 1/2/3, PCI DSS, HIPAA, GDPR alignment.
  • AWS Artifact: self-service portal to download audit reports and agreements.

C. Working with AWS CLI

The AWS Command Line Interface drives all services from a terminal, scriptable and automatable.

  • Install and configure: aws configure stores access key, secret key, default Region and output format in ~/.aws/credentials and ~/.aws/config.
  • Command shape: aws <service> <operation> [--parameters].
  • Profiles: --profile switches between accounts/roles.
  • Output: JSON (default), table or text, filterable with --query (JMESPath).
BASH
aws configure
aws ec2 describe-instances --output table --region us-east-1

IV. Amazon EC2

A. Introduction to EC2

Amazon Elastic Compute Cloud provides resizable virtual servers (instances) launched from templates.

  • AMI (Amazon Machine Image): the template holding OS, software and config used to boot an instance.
  • Instance type: defines vCPU, memory, network and storage (e.g. t3.micro, m5.large); families target general, compute, memory, storage and accelerated workloads.
  • Key pair: public/private keys for authenticating login.

B. Configure Instance Behavior

Instances can run startup logic and metadata-driven settings automatically.

  • User data: a script passed at launch, run once at first boot (e.g. install a web server).
  • Instance metadata: retrieved from http://169.254.169.254/latest/meta-data/ to read instance ID, IP, IAM role credentials.
  • Shutdown behavior: choose whether OS shutdown stops or terminates the instance.
BASH
#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd

C. Placement Groups

Placement groups control how instances are physically positioned to meet latency or resilience needs.

  • Cluster: packs instances close in one AZ for low-latency, high-throughput HPC networking.
  • Spread: places instances on distinct hardware racks (max 7 per AZ) to minimise correlated failure.
  • Partition: groups instances into partitions on separate racks for large distributed systems (Hadoop, Cassandra).

D. Instance Pricing

AWS offers several purchasing models trading commitment for cost.

  • On-Demand: pay per second/hour, no commitment; best for spiky or unknown workloads.
  • Reserved Instances / Savings Plans: 1- or 3-year commitment for up to ~72% discount.
  • Spot Instances: bid on spare capacity for up to ~90% off, but can be reclaimed with a 2-minute warning; suits fault-tolerant batch jobs.
  • Dedicated Hosts: physical server dedicated to you, for licensing or compliance.

E. Instance Lifecycle

An instance moves through defined states that affect billing.

  • pending → running: booting, then billed.
  • stopping / stopped: EBS-backed only; no compute charge, EBS storage still billed; public IP released unless Elastic IP.
  • rebooting: stays on same host, keeps data and IP.
  • terminating / terminated: permanently deleted; root EBS volume deleted by default.

F. Resource Tags

Tags are key–value metadata for organising and governing resources.

  • Structure: up to 50 tags per resource, e.g. Environment=Prod, Owner=TeamA.
  • Uses: cost allocation reports, access control via IAM conditions, automation targeting, filtering in the console.

G. Service Limits

Service limits (quotas) cap how many resources an account can create.

  • Examples: default On-Demand vCPU limits per Region, Elastic IPs per Region (5 by default).
  • Management: viewed and raised through the Service Quotas console or a support request.
  • Purpose: protect against runaway cost and accidental over-provisioning.

V. EC2 Storage

A. EC2 Storage volumes

Elastic Block Store (EBS) provides persistent, network-attached block storage.

  • Persistence: survives instance stop/terminate (if not set to delete); independent lifecycle.
  • Volume types: SSD gp3/gp2 (general purpose), io1/io2 (provisioned IOPS, databases), HDD st1 (throughput), sc1 (cold archive).
  • Snapshots: incremental backups stored in S3; used to create AMIs or restore volumes.
  • Attachment: one volume to one instance in the same AZ (except io1/io2 Multi-Attach).

B. Instance store Volumes

Instance store is temporary block storage physically attached to the host.

  • Ephemeral: data lost on stop or terminate, but survives reboot.
  • Performance: very high I/O since local to hardware; good for caches, buffers, scratch data.
  • No separate charge: included in instance cost; cannot be detached or snapshotted.
  • Contrast with EBS: EBS = durable, network-attached, persistent; instance store = fast, local, volatile.

VI. Accessing and Securing EC2

A. Accessing Your EC2 Instance

Access depends on OS and credentials established at launch.

  • Linux: SSH on port 22 using the private key: ssh -i key.pem ec2-user@<public-ip>.
  • Windows: RDP on port 3389 with password decrypted via the key pair.
  • Session Manager: browser/CLI shell with no open inbound ports or keys, via SSM agent.
  • Elastic IP: static public IPv4 that persists across stop/start.

B. Securing Your EC2 Instance

Security combines network controls, identity and host hardening.

  • Security groups: stateful virtual firewalls allowing specified inbound/outbound ports and sources; default deny inbound.
  • Network ACLs: stateless subnet-level rules as a second layer.
  • IAM roles: attach a role so the instance obtains temporary credentials instead of stored keys.
  • Hardening: least-privilege rules, restrict SSH to known IPs, patch the OS, encrypt EBS volumes.

VII. Scaling and Management

A. EC2 Auto Scaling

Auto Scaling maintains the right number of instances automatically.

  • Launch template: defines what to launch (AMI, type, key, security group).
  • Auto Scaling group (ASG): sets minimum, desired and maximum capacity across AZs.
  • Scaling policies: target tracking (keep CPU ≈ 50%), step, or scheduled scaling.
  • Health checks: replaces failed instances automatically, giving self-healing and cost control.

B. AWS Systems Manager

Systems Manager (SSM) centralises operational control of fleets.

  • Fleet Manager / Run Command: execute commands across many instances without SSH.
  • Session Manager: secure shell access without open ports or key pairs.
  • Parameter Store: store config and secrets, retrieved by instances via IAM.
  • Patch Manager: automate OS patching on a schedule.

C. AWS CLI Examples

Common EC2 operations expressed through the CLI tie the unit together.

BASH
# Launch an instance
aws ec2 run-instances --image-id ami-0abc123 \
  --instance-type t3.micro --key-name mykey \
  --security-group-ids sg-01234 --count 1

# Tag it
aws ec2 create-tags --resources i-0abc \
  --tags Key=Environment,Value=Prod

# Stop, start, terminate
aws ec2 stop-instances --instance-ids i-0abc
aws ec2 start-instances --instance-ids i-0abc
aws ec2 terminate-instances --instance-ids i-0abc

# Create and attach an EBS volume
aws ec2 create-volume --size 20 --volume-type gp3 \
  --availability-zone us-east-1a
aws ec2 attach-volume --volume-id vol-0abc \
  --instance-id i-0abc --device /dev/sdf
  • Pattern: every console action maps to a describe, create, run, modify or delete operation, making infrastructure fully scriptable and repeatable.