Cheat Sheet 1: Infrastructure as Code
| Concept | Key point |
|---|---|
| IaC | Infrastructure defined in version-controlled files and applied by a tool |
| Declarative | Describe the end state. Terraform works out the steps. |
| Imperative | Describe the steps, as in scripts and CLIs |
| Idempotent | Re-applying unchanged config produces "No changes" |
| Execution order | Comes from the dependency graph (references), never from file or block order |
| Parallelism | Independent resources are created concurrently, 10 by default |
| Desired vs. actual | Config is desired state. State plus refresh gives actual state. Plan is the difference. |
| Benefits | Version control, review via plan, consistency, reuse via modules, self-documentation, drift detection, automation |
| Immutable infra | Replace rather than modify. Shown as -/+ and # forces replacement in a plan. |
| Providers | Plugins that hold all platform logic. Core is platform-agnostic. |
| Multi-cloud | Many cloud providers, one workflow |
| Hybrid | On-premises (such as vSphere) plus cloud, one workflow |
| Service-agnostic | Non-infrastructure APIs: GitHub, DNS, monitoring, identity, Kubernetes, Vault |
| Not abstracted | Resources are provider-specific. aws_* blocks don't run on Azure. |
| Terraform vs. config management | Terraform provisions. Ansible, Chef, and Puppet configure inside servers. They complement each other. |
| Provisioners | A last resort per HashiCorp docs |
Commands seen so far: terraform version · init · fmt -check · validate · plan · apply · state list · output · destroy
Plan symbols: + create · - destroy · ~ update in place · -/+ replace (destroy, then create) · +/- replace with create first (create_before_destroy) · <= read a data source
Module 1 self-check
Module 1 self-check.
- Objectives 1a, 1b, and 1c are each covered by a lesson, the lab, and at least two knowledge-check questions.
- The lab HCL uses
fmt-aligned formatting and validrandomandlocalprovider arguments. - Every expected output matches Terraform 1.12 CLI wording.
- The cross-provider Cloudflare and GitHub snippet is marked illustrative.
- All 10 answers are rechecked against Terraform's documented behavior.