Cloud Fundamentals
EngineerCode / policy labScenario sim

Infrastructure as Code and Immutability

Turn infrastructure changes into reviewed, reproducible deployments without mistaking state, plans, or images for security guarantees.

55 min 195 XPSkills: Change control, State protection, Immutable deployment

Brief

At Halcyon Clinics, an engineer adds a temporary public administration rule during an outage. The next deployment removes it, but nobody can explain why it existed for six hours. Meanwhile, a shared infrastructure state file contains a generated database password, and the release manager calls the latest machine image immutable even though operators still patch running machines by hand.

The team needs more than infrastructure written in text files. It needs an explicit desired configuration, protected resource mappings, a reviewable change calculation, and deployment evidence that identifies what actually ran. This room follows a three-instance application through a change and separates reproducibility, confidentiality, availability, and authorization: each needs its own control.

Versioned configuration records intent; only linked approval, execution, and verification records demonstrate an authorized change.

Declare the destination, then calculate the route

An imperative procedure says create a network, then create an instance, then attach a rule. A declarative configuration says three instances must exist, each attached to the private network and the approved rule set. If two instances already exist, an engine compares configuration with managed resource mappings and refreshed remote attributes to calculate the missing work. Repeating a well-designed convergence operation should not add three more instances. Declarative syntax alone does not guarantee idempotence: external scripts and unmanaged resources can still introduce side effects.

Desired state is the approved target, not the last successful deployment. A reusable module can encode a private application tier with typed inputs for instance count and image identifier, validation that count is at least two, and outputs for resource identifiers. Pin its revision: changing a shared module from version 4 to 5 may alter every consuming environment. Modules reduce duplication, but a weak default such as public administration access can multiply exposure across twenty deployments.

For configuration management controls, retain the reviewed source revision, pinned module revision, input values without secrets, and test results. An auditor can ask whether all twenty environments used the reviewed module version and whether exceptions to its network defaults were explicitly approved; a reusable folder alone proves neither.

State is a sensitive map, not the desired configuration

A state file commonly maps a logical address such as application.node[0] to a remote resource identifier and cached attributes. It may also retain generated passwords, connection strings, or sensitive output values. Hiding a value from terminal output does not necessarily remove it from state. Treat state and saved plans as sensitive artifacts: restrict readers and writers, encrypt storage and transport, audit access, and keep them out of ordinary source history. Removing a leaked file from the latest revision does not revoke exposed credentials or erase earlier copies.

Use a protected shared backend with locking or equivalent serialization so two writers do not both plan against state generation 18 and overwrite each other's mappings. Separate production and test state boundaries and credentials. Maintain versioned backups and rehearse restoration: an old state copy can reference deleted objects or omit newer ones, so restoration requires reconciliation before any destructive apply. A lock prevents competing state writes; it does not prevent someone changing a resource through another management channel.

Least-privilege and recovery evidence includes state access logs, backend access policy, lock behavior tests, and a dated restore exercise. An auditor should ask who can download historical versions and how a restored mapping is checked against actual resources, not merely whether the backend reports encryption enabled.

Plans, approvals, and drift form a change chain

A plan calculates proposed operations; apply executes them. For a change from three to four instances, a plan might report one create, zero updates, and zero deletes. A replacement is different: changing a boot image may require creating a new instance and destroying the old one. Review deletions, replacements, dependencies, permissions, and data persistence rather than approving on the basis of a small line count. Apply can partially fail; a plan is not a transaction guarantee or proof that access will succeed.

Bind approval to the source revision, environment, inputs, and saved plan digest. Restrict apply to a deployment identity separate from the author, and verify the applied artifact matches the approved one. If state or inputs have changed, invalidate the old approval and calculate a fresh plan for review. Scheduled refresh-and-compare runs detect drift: if the approved rule allows administration only from 10.24.8.0/24 but the live rule allows 0.0.0.0/0, raise an incident. Do not silently import the public rule into code to make the difference disappear.

Retain approval identity and timestamp, plan digest, execution logs, and post-deployment verification under one change identifier. Drift findings need an owner, response deadline, and documented resolution: revert unauthorized changes or approve a justified target change through review. An auditor sampling an emergency change should be able to trace detection through authorization or remediation, including any period of exposure.

Five boxes show source revision R42, refreshed state generation 18, plan P7 with one create and zero deletes, independent approval bound to digest, and apply receipt. Arrows connect calculation to execution; a separate live public rule comparison branches to a drift incident, not automatic acceptance.
Approval must bind to the calculated change, while drift takes a separate investigation path.

Replace machines; preserve data deliberately

Immutable infrastructure replaces deployed units instead of repairing them in place. Build golden image release 12 from reviewed inputs, patch and scan it, record its digest and test results, and deploy that exact artifact. A golden image is an approved baseline, not a promise of permanent safety: new vulnerabilities still require rebuilding and replacing it. Keep credentials out of images and inject short-lived access at runtime; otherwise every replacement reproduces the same secret exposure.

For a three-instance service, create three release-12 replacements alongside release 11, check health, shift traffic, and retire the old group after observation. Capacity temporarily rises from three to six; quota and cost must support the overlap. Store durable records outside replaceable compute. Rolling back traffic to release 11 can restore application behavior but cannot undo a destructive database migration; use compatible schema transitions and independently tested backups rather than calling an old image a data recovery plan.

Baseline and vulnerability controls need image provenance, scan dates, digest pinning, deployment inventory, and proof that old instances were retired. Code review is change control only when required approvals cannot be bypassed unnoticed and the reviewed artifact is the deployed one. An auditor should ask whether running image digests match approved releases and whether emergency access left any long-lived, hand-patched exceptions.

A build box produces scanned image release 12 with a pinned digest. Two parallel groups contain three release-11 instances and three release-12 instances. Health checks gate a traffic arrow moving between groups. Both connect to external durable storage; a warning marks schema changes as outside image rollback.
Replacement changes the compute release without pretending that application rollback restores data.

Tasks

Answers are graded on the server: the answer key never reaches your browser.

Task 1: The misleading script label

Scenario sim+65 XP

Read the brief and answer both questions.

Incident brief

An engineer labels a file 'declarative' because it is stored as text. It executes create-instance three times without inspecting existing resources, so every rerun adds three machines. A second file instead specifies that exactly three instances must exist. The manager calls both approaches identical.

Term bank, not all of these are right

imperativedesired statedeclarativestate file

1.1Which approach describes the first file's ordered commands? (one word)

1.2What is the approved target configuration represented by the second file called? (two words)

Task 2: A safe-looking download

Scenario sim+65 XP

Read the brief and answer both questions.

Incident brief

A release lead posts a resource mapping artifact to a broadly readable folder, arguing that masked terminal outputs make it safe. The artifact contains a generated password. Separately, a scheduled comparison finds that a live network rule differs from approved configuration; the lead insists the difference is merely a new desired state, although no change was authorized.

Term bank, not all of these are right

state filedriftgolden imagedesired state

2.1Which artifact mapping logical resources to remote identifiers was exposed? (two words)

2.2What is the live rule's unapproved divergence called? (one word)

Task 3: The deployment that never happened

Scenario sim+65 XP

Read the brief and answer both questions.

Incident brief

An operator presents a calculation showing three replacements and declares the deployment complete, though no execution occurred. The approved design requires replacing running machines from a patched image rather than editing them in place. A colleague proposes manually patching those machines and retaining the immutable label.

Term bank, not all of these are right

applyimmutable infrastructureplanmutable infrastructure

3.1Which phase must execute the calculated operations? (one word)

3.2What infrastructure model replaces deployed units rather than modifying them in place? (two words)

Labs

80 bonus XP

Hands-on work. You edit the artefact, the server runs the checks: the expectations and the reference solution never reach your browser.

Lab 1 · YAML lab

Specify a controlled replacement release

Briefing 40 XP

Halcyon Clinics wants a replacement release for its application tier. The release lead says the plan is already an approval and suggests committing state beside configuration because output values are masked. Neither claim satisfies the release policy.

Complete the policy using the fixture's fixed values and safeguards. This is an executable policy specification exercise, not infrastructure provisioning: the evaluator checks the declared release controls, while real enforcement would require a deployment pipeline and backend configuration.

Mandatory release requirements

environment: production
replicas: exactly 3
module_revision: tier-4
image_digest: sha256:8a61c4
state: shared protected backend; encryption and locking required; never in source history
approval: independent reviewer; bind approval to saved plan digest
change: replace running instances; do not patch in place
drift: check every 60 minutes; investigate differences before remediation

Checks

  • Use the exact replica count and pinned module revision
  • Pin the approved image digest
  • Protect and serialize state outside source history
  • Bind independent approval to the saved plan
  • Use replacement rather than in-place repair
  • Schedule comparison and investigate differences
Lab 2 · Review lab

Review the change-control evidence

Briefing 40 XP

The release manager labels every entry compliant because all six mention code or images. Review each entry as a separate claim against the control baseline; do not infer missing safeguards from another entry.

The baseline requires confidential state, approval of the exact applied plan, investigation of unauthorized drift, and replacement-based immutable updates. Reject violations using the single closest reason code; accept evidence that explicitly satisfies its claim.

Verdicts are accept or reject. Every rejection needs one reason code from: state-exposure | approval-mismatch | drift-adoption | mutable-update.

Six independent release claims

CI-1 | State download is open to all staff; generated credentials remain in the file. Terminal masking is cited as protection.
CI-2 | Plan digest A was approved. New inputs produced digest B, which was applied without another review.
CI-3 | A public administration rule appeared without approval. The team copied it into configuration solely to silence the comparison alert.
CI-4 | The immutable-update claim relies on operators patching every running instance in place while keeping the original image label.
CI-5 | The authorization claim links a reviewed source revision and saved plan digest to an independent approver and matching deployment receipt; logs show no bypass.
CI-6 | The replacement claim links a scanned image digest to new healthy instances, traffic cutover, and retirement of old instances; durable data stayed external.

Checks

  • Every line in the fixture carries a verdict
  • Accept and reject land on the right lines
  • Each rejection cites a valid reason code

Next on your path · Cloud Fundamentals

Cloud Logging, Monitoring and Posture

Distinguish administrative changes from data access, protect central audit evidence, and turn configuration findings into verified remediation.

Engineer 55 min 195 XP
Start next room

Community

Discussion & writeups

Sign in to post

Share how you approached the room or ask where you got stuck. Never paste task answers or full lab solutions: write the reasoning, not the key.

Loading discussion…