Chapter Two

The Core Workflow

The three-phase plan/apply cycle, how resources are addressed, how data sources read the world, and how the dependency graph decides the order of everything — the mechanics underneath every Terraform run.

6 topics

Chapter 1 gave you the loop: write a config, init, plan, apply. This chapter takes the lid off that loop. Every apply is a refresh, a diff, and an execution — and once you can read a plan line by line, infrastructure review becomes the same skill as code review.

The order in which Terraform creates and destroys resources is not the order you wrote them in. It comes from a dependency graph Terraform builds for itself, mostly from the references between resources. The six topics here cover that graph, the data sources that feed it values from outside, the addressing syntax every operational command needs, and the lifecycle block that overrides the defaults when you need zero-downtime replacement or a guardrail on a database.

Topics in This Chapter