Chapter Three

The Core Workflow

The refresh/plan/apply loop that drives every change you make on Google Cloud, how to read a plan the way you read a code review, and the four mechanisms — resources, data sources, dependencies, and lifecycle rules — that decide what Terraform builds and in what order.

6 topics

Every change to your GCP infrastructure runs the same three-phase loop: Terraform refreshes state by reading the live resources from the Google Cloud APIs, plans the diff between that reality and your HCL, and applies the API calls that close the gap. This chapter is that loop, examined slowly, plus the four mechanisms underneath it that decide what gets built and when.

The running example is Layer A of the Hatch pipeline — the hatch-events-raw bucket, the events-ingest topic, the event-processor Cloud Run service, and the analytics BigQuery dataset, all living in hatch-pipeline-dev. You will learn to read a plan, address a resource, look up what you do not own with a data source, wire dependencies that Terraform infers from references, see the whole thing as a graph, and reach for lifecycle rules when the default destroy-then-create would cause an outage.

Topics in This Chapter