Batch 4: Cloud Ansible AWS & Azure Docker Apache & NGINX ← Full TOC

← Cloud Index

☁️ Cloud Fundamentals — IaaS, PaaS, SaaS, regions, availability zones, VPC

Cloud computing delivers on-demand IT resources over the internet. Understanding the service models (IaaS/PaaS/SaaS), deployment models, and shared responsibility model is foundational to working with any cloud provider.

📋 Reference

Term / ServiceDescription / ValueNotes
IaaSInfrastructure as a ServiceVMs, storage, networking — you manage OS and above (EC2, Azure VMs, GCE)
PaaSPlatform as a ServiceManaged runtime — you manage app and data (App Service, Heroku, GAE)
SaaSSoftware as a ServiceFully managed app — you just use it (Gmail, Salesforce, Office 365)
FaaSFunction as a Service / ServerlessRun code without managing servers (Lambda, Azure Functions, Cloud Run)
CaaSContainer as a ServiceManaged Kubernetes (EKS, AKS, GKE)
Public cloudResources shared across customers, owned by providerAWS, Azure, GCP, Oracle Cloud
Private cloudDedicated resources for one org, on-premises or hostedOpenStack, VMware, on-prem k8s
Hybrid cloudMix of public and private cloud with interconnectVPN or Direct Connect between on-prem and cloud
Multi-cloudUsing multiple public cloud providersAvoid vendor lock-in, use best-of-breed
RegionGeographic area containing multiple data centersus-east-1, eastus, us-central1
Availability ZoneIsolated data center(s) within a regionus-east-1a, us-east-1b — for high availability
Edge LocationCDN point of presence close to end usersCloudFront, Azure CDN, Cloud CDN pops
VPCVirtual Private Cloud — isolated network in the cloudYour own private network within the cloud
SubnetSubdivision of a VPC with CIDR blockPublic subnet (has IGW route) vs private subnet
CIDRClassless Inter-Domain Routing: 10.0.0.0/16Defines IP range for VPC and subnets
Internet GatewayIGW — connects VPC to the public internetRequired for public subnets to reach internet
NAT GatewayNetwork Address Translation — outbound internet for private subnetsPrivate instances access internet, not accessible from internet
Route TableRules directing traffic within VPC0.0.0.0/0 via IGW = internet access
Security GroupStateful virtual firewall at instance levelAllow inbound 443, 22 — deny everything else
NACLNetwork Access Control List — stateless, at subnet levelStateless: must allow inbound AND outbound
Load BalancerDistribute traffic across multiple instancesALB (HTTP/S), NLB (TCP), Classic (legacy)
Auto ScalingAutomatically add/remove instances based on demandScale out on high CPU, scale in at night
CDNContent Delivery Network — cache at edge locationsCloudFront, Azure CDN, Cloudflare
IAMIdentity and Access Management — who can do whatUsers, roles, policies, permissions
CapEx vs OpExCapital Expenditure vs Operational ExpenditureCloud shifts from buying hardware (CapEx) to paying monthly (OpEx)
Shared ResponsibilityProvider manages hardware/hypervisor; customer manages OS/appsSecurity of the cloud vs security in the cloud

💡 Example

# Cloud Architecture Concepts — Visual Reference

# ── VPC Network Design ────────────────────────────────────────
#
#  Region: us-east-1
#  VPC: 10.0.0.0/16
#  ┌─────────────────────────────────────────────────────────┐
#  │                                                         │
#  │  AZ: us-east-1a              AZ: us-east-1b            │
#  │  ┌──────────────────┐        ┌──────────────────┐      │
#  │  │ Public Subnet    │        │ Public Subnet    │      │
#  │  │ 10.0.1.0/24      │        │ 10.0.2.0/24      │      │
#  │  │ [Web Servers]    │        │ [Web Servers]    │      │
#  │  │ [Load Balancer]  │        │ [Load Balancer]  │      │
#  │  └──────────────────┘        └──────────────────┘      │
#  │                                                         │
#  │  ┌──────────────────┐        ┌──────────────────┐      │
#  │  │ Private Subnet   │        │ Private Subnet   │      │
#  │  │ 10.0.3.0/24      │        │ 10.0.4.0/24      │      │
#  │  │ [App Servers]    │        │ [App Servers]    │      │
#  │  │ [Databases]      │        │ [DB Replica]     │      │
#  │  └──────────────────┘        └──────────────────┘      │
#  │                                                         │
#  │  Internet Gateway ←→ Public Subnets                    │
#  │  NAT Gateway → Private Subnets (outbound only)         │
#  └─────────────────────────────────────────────────────────┘

# ── Service Model Comparison ──────────────────────────────────
#
#  You manage:        SaaS    PaaS    IaaS    On-Prem
#  Applications        ✗       ✓       ✓        ✓
#  Data                ✗       ✓       ✓        ✓
#  Runtime             ✗       ✗       ✓        ✓
#  Middleware          ✗       ✗       ✓        ✓
#  OS                  ✗       ✗       ✓        ✓
#  Virtualization      ✗       ✗       ✗        ✓
#  Servers/Storage     ✗       ✗       ✗        ✓
#  Networking          ✗       ✗       ✗        ✓
#
#  Provider manages:  SaaS    PaaS    IaaS    On-Prem
#  Virtualization      ✓       ✓       ✓        ✗
#  Servers/Storage     ✓       ✓       ✓        ✗
#  Networking          ✓       ✓       ✓        ✗
#  Runtime             ✓       ✓       ✗        ✗
#  Applications        ✓       ✗       ✗        ✗

# ── Security Group Rules (AWS example) ───────────────────────
#
#  Web Server Security Group:
#  Inbound:
#    Type    Protocol  Port    Source
#    HTTPS   TCP       443     0.0.0.0/0  (internet)
#    HTTP    TCP       80      0.0.0.0/0  (redirect to HTTPS)
#    SSH     TCP       22      10.0.0.0/8 (corporate VPN only)
#  Outbound:
#    All traffic  All  All     0.0.0.0/0  (allow all outbound)
#
#  Database Security Group:
#  Inbound:
#    PostgreSQL  TCP  5432  sg-webservers-id  (app servers only!)
#    MySQL       TCP  3306  sg-webservers-id
#  Outbound: (restrict or allow all)
#
#  Best practice: reference security groups, not CIDR blocks
#  for internal traffic — security groups auto-update when IPs change

# ── IAM Policy Example (JSON) ────────────────────────────────
iam_policy = {
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "S3ReadOnlyAccess",
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:ListBucket"],
      "Resource": [
        "arn:aws:s3:::mywebuniversity-content",
        "arn:aws:s3:::mywebuniversity-content/*"
      ]
    },
    {
      "Sid": "DenyDeleteObjects",
      "Effect": "Deny",
      "Action": ["s3:DeleteObject", "s3:DeleteBucket"],
      "Resource": "*"
    }
  ]
}

import json
print(json.dumps(iam_policy, indent=2))

# ── Auto Scaling Policy ───────────────────────────────────────
# Scale out: add 2 instances when CPU > 70% for 5 minutes
# Scale in:  remove 1 instance when CPU < 30% for 10 minutes
# Cooldown:  300 seconds between scaling actions
# Min: 2, Max: 20, Desired: 4

🏠 Index  |  Compute & Storage →