Learning SequenceVol. 18 · Part XVIII
0 / 0

Trails / Learning Sequence

LS·203

Phase 7 — Cloud and DevOps

The seventh phase: cloud fundamentals, IAM, networking, managed databases, object storage, cloud compute and Kubernetes, Terraform, CI/CD and GitOps, ending with your application deployed to one cloud with automated infrastructure and delivery; the order and why, an entry check, step-by-step exit checks mapped to Volumes 7 and 8, the project with milestones and definitions of done, traps, a time budget, and a lab that tests what infrastructure-as-code state does and doesn't know.

16 topics · ~7 min read · 16-question quiz
Updated Suggest a correction

Start here: Phase 7 in one page

Phase 6 ran the application on your machine. Phase 7 runs it in a public cloud, with everything (networks, databases, permissions, clusters) described as code and every change delivered by a pipeline. Pick one cloud (AWS, Azure or GCP); the concepts transfer, and depth in one beats a tour of three.

The sequence

Text
Cloud fundamentals → IAM → VPC/network → managed DB → object storage → Kubernetes/cloud compute → Terraform → CI/CD → GitOps

Identity first, because every other service is accessed through it and most cloud breaches are permission mistakes. Networking next, because everything lives in it. Then the managed building blocks your app needs. Then infrastructure as code to create them repeatably, CI/CD to deliver application changes, and GitOps to keep running systems matching what's in Git.

What infrastructure as code knows, and doesn't

The lab used OpenTofu (the open-source Terraform fork) on a tiny configuration describing a "deployment" of 2 replicas:

Action What the tool said What actually happened
first apply 1 to add created
plan again No changes nothing to do: idempotent
change replicas 2 → 3, apply 1 changed state says 3 replicas; the deploy command did not run again (provisioners run only on create)
someone edits the deployed thing by hand No changes the drift went unnoticed

IaC tools know only what their providers can read back. Real cloud providers do read real resources and detect most drift; scripts bolted on with provisioners don't. Knowing what your state file can and can't see is the difference between "it's all in Terraform" and infrastructure you can trust.

How deep to go in Phase 7

Volume 17 defines six mastery levels; Phase 7's exit targets are:

Topic Exit level What that means here
cloud fundamentals L2–L3 regions, zones, shared responsibility, pricing basics
IAM L3 identities, roles, policies, least privilege, workload identity
networking L2–L3 VPCs, subnets, routing, security groups, private endpoints
managed DB and object storage L2–L3 provisioning, backups, encryption, access
compute and managed Kubernetes L2–L3 choose VMs, containers or serverless; run a cluster
Terraform/OpenTofu L3 modules, state, plans, drift, environments
CI/CD and GitOps L3 pipelines with gates; Argo CD or Flux

The sequence, step by step

Step Learn Read Exit check
1 cloud fundamentals and well-architected thinking Vol. 7, Start Here, ch. 85, 91 explain regions, zones and the shared-responsibility model
2 identity Vol. 7, ch. 89 a least-privilege role for your app, tested by a denied action
3 networking Vol. 7, ch. 87 a VPC with public and private subnets; database not internet-reachable
4 storage and managed databases Vol. 7, ch. 88 encrypted bucket and database with backups
5 compute and cloud architecture Vol. 7, ch. 86, 90 choose and justify a compute option for your app
6 Git and CI/CD Vol. 8, ch. 92–93 a pipeline that tests, builds, signs and deploys
7 infrastructure as code Vol. 8, ch. 94 all infrastructure from code; plan clean after apply
8 GitOps and release engineering Vol. 8, ch. 95–96 Argo CD or Flux syncing the app; a rollback by Git revert

Entry check

Phase 6's project: a containerised application running on a local Kubernetes cluster.

The phase project: deploy to one cloud with automated infrastructure and delivery

Goal. Your application running in one cloud, with every resource created by IaC and every change delivered by a pipeline.

Milestones. Account/project structure and budget alerts → IaC modules: network, database, bucket, cluster or compute, DNS and TLS → remote state with locking → CI with OIDC to the cloud (no long-lived keys) → image build, scan, sign and push → GitOps deployment to the cluster → environment separation (staging and production) → a teardown and rebuild from scratch → a cost report.

Done when. plan is clean after apply; a full rebuild from an empty account works from the README; no human holds long-lived admin keys; a bad release is rolled back by reverting a commit; monthly cost is known and alerted.

Stretch. Policy as code (OPA/Conftest or Checkov) failing the pipeline on public buckets or open security groups.

Common traps

  • Click-ops: resources created by hand that IaC doesn't know.
  • Admin credentials everywhere, including CI.
  • Public databases "just for testing".
  • No budget alerts, and a surprise bill.
  • Provisioner scripts doing work the tool can't track.

Exit criteria

  • [ ] The project meets its "done when" list.
  • [ ] I can explain a cloud IAM policy evaluation and fix an access-denied error.
  • [ ] I can design a VPC for a three-tier app.
  • [ ] I can explain Terraform state, plans, drift and modules.
  • [ ] I scored at least 80% on 40 questions from Volumes 7–8's quizzes, twice.

Time budget

Volumes 7 and 8 are about 63,000 words (under 5 hours of reading); with practice, about 18 hours, plus 3–4 weeks for the project: about 6–7 weeks at 8 hours a week. Keep cloud costs low with small instances, short-lived environments and teardown scripts.

Lab: what infrastructure-as-code state knows

Setup. OpenTofu 1.13.2 on the lab machine. Scope: the lab can't reach cloud provider APIs or the provider registry, so it uses OpenTofu's built-in terraform_data resource (which needs no provider) with a local-exec provisioner that "deploys" by writing a file. That's enough to show how plans, state, idempotence and drift work, and to show a real limitation; real cloud providers read actual resources, which changes Experiment 4's result (see below).

HCL
variable "replicas" { default = 2 }
variable "image"    { default = "tiffin-api:1.4.0" }
resource "terraform_data" "deployment" {
  input = { replicas = var.replicas, image = var.image }
  provisioner "local-exec" { command = "echo 'deploying ${var.image} x${var.replicas}' > ${path.module}/deployed.txt" }
}

Results

Step Tool output Reality
1. apply Plan: 1 to add → Apply complete! 1 added deployed.txt written
2. plan again No changes. Your infrastructure matches the configuration. idempotent
3. plan -var replicas=3 ~ replicas = 2 -> "3", Plan: 0 to add, 1 to change an in-place update
4. hand-edit deployed.txt, then plan No changes. drift went unnoticed
5. apply -var replicas=3 (file reset to "original" first) Apply complete! 1 changed; output replicas = "3" file still says "original": the provisioner didn't run

What it shows

  • Plans compare three things: configuration, state, and (via providers) reality. Step 2's "No changes" is idempotence: applying again does nothing once they match.
  • Provisioners run at creation, not on update. Step 5 recorded 3 replicas in state while nothing happened in the "real" system: a state file that lies. That's why provisioners are a last resort; use resources whose providers manage the real thing (or replace on change with replace_triggered_by).
  • Drift is visible only through providers. With a real cloud provider, step 4's hand edit to, say, a security group would appear in plan as a change to revert, because the provider refreshes the resource from the cloud API. Changes to things no provider reads (files on a VM, settings changed inside an application) stay invisible, which is one reason GitOps controllers that continuously reconcile are used for what runs inside clusters.

Try it yourself

  1. Add lifecycle { replace_triggered_by = [terraform_data.deployment.input] } (or an equivalent trigger) so changes re-run the deploy, and repeat step 5.
  2. With a free-tier cloud account, create a security group with OpenTofu, edit a rule in the console, and watch plan detect it.
  3. Move state to a remote backend with locking and run two applys at once.
  4. Run tofu plan -detailed-exitcode on a schedule and alert when it returns 2 (drift).

Revision sheet: Phase 7, cloud and DevOps

Key ideas

  • Sequence: fundamentals → IAM → network → managed DB → object storage → compute/Kubernetes → Terraform → CI/CD → GitOps.
  • One cloud in depth; least privilege everywhere; private by default.
  • IaC: plan compares config, state and reality; idempotent applies; drift visible only through providers.
  • CI/CD with OIDC, signed artefacts and gates; GitOps reconciles continuously from Git.

Numbers to remember

  • Lab: second plan "No changes"; a 2 → 3 change updated state but not the provisioned file; a hand edit wasn't detected.
  • Budget: ~18 study hours + 3–4 project weeks ≈ 6–7 weeks at 8 h/week.

Pitfalls

  • Click-ops and provisioner scripts.
  • Long-lived admin keys, especially in CI.
  • Public databases and buckets.
  • No budget alerts; no teardown.

Glossary

  • IaC: infrastructure as code.
  • State file: the IaC tool's record of what it manages.
  • Drift: real infrastructure differing from code.
  • OIDC federation: exchanging a CI identity token for short-lived cloud credentials.
  • GitOps: Git as the source of truth, reconciled by an in-cluster controller.