Track 08 · Deployment & opsLesson 03 of 11
Infrastructure as code for agents
Rebuild dev, staging and production on demand.
- Lesson library · reference
- 30 min read
- 75 min hands-on
- Pro
What you'll be able to do
01- Explain how a declarative IaC tool reconciles configuration, state and real infrastructure into a plan, and why state is the most sensitive artefact in the repo.
- Choose between Terraform, OpenTofu, CloudFormation/CDK, Pulumi and Bicep for a customer, and defend the choice against licence, estate and skills constraints.
- Design a module and environment layout where dev, staging and production differ only by reviewed inputs.
- Implement a policy check over a JSON plan that blocks public buckets, off-region model access, missing tags, secrets in state and unapproved production destroys.
- Diagnose drift and decide whether to revert it, adopt it into code or reassign ownership.
Before you start
- Deploying into the customer's cloud: the accounts, SCPs and promotion model this file codifies.
- Secrets, dependencies and network isolation and Agent credentials, from issue to revoke: the secrets and workload identities your IaC references.
- Regression tests and CI gates: the gate pattern reused here for plans.
- Background: you have run
terraform init,planandapplyat least once.
The short version
Infrastructure-as-code describes the environment an agent runs in (model endpoints, vector store, queues, secret references, IAM roles, guardrail configuration, monitors and on-call services) as versioned files. The tool compares those files with its recorded state and with reality, produces a plan, and applies only what the plan says. Reproducibility comes from three habits: one set of modules for every environment, with differences confined to small reviewed input files; remote, locked, encrypted state that never holds secret values; and every plan checked by policy and read by a human in the pull request before production changes.
- The plan is the unit of review, not the code diff.
- State is a secrets-bearing database. Encrypt it, lock it, restrict it, and keep secret values out of it.
- Environments differ by inputs, never by copy-pasted code.
- Policy as code turns the customer's guardrails into failing checks before apply.
- Drift means production changed outside the pipeline. Find out why before you touch it.
Pro lesson
The rest of this lesson is in Pro.
The mental model, worked example, field note, failure table, exercise and self-check, with the voice tutor.
- Every stage and specialisation, in full
- Every lab and every role project
- Halden weeks 2–10, on your record
- Every drill, live in the playground
- All solutions, plus the server judge
- Lab Assistant and every Teach with AI