4.1. Resources and Data Sources
💡 First Principle: A configuration describes infrastructure with exactly two intents — "Terraform should manage this" (a resource) and "Terraform should read this" (a data source) — and keeping that distinction sharp explains why Terraform creates some things and merely looks up others.
Why care: Confusing resources and data sources leads to real damage: thinking a data block will "create if missing," or expecting a resource block to "just read." The exam tests the boundary directly, and getting it wrong in production can mean Terraform tries to destroy something it should only have read.
The mental model: A resource is a possession Terraform owns and is responsible for; a data source is a reference Terraform looks up but never touches. Owning vs. consulting.
⚠️ Common Misconception: "A data block can create the thing it points to if it doesn't exist." It cannot. A data source only reads existing objects; if the target doesn't exist, the data lookup fails — it never provisions anything.