liveBook · Manning

Source of truth

As explained in Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu

A source of truth is the authoritative representation against which the state of a system is evaluated and corrected.

A source of truth is the authoritative representation used to evaluate and correct a system’s state. For infrastructure, centralizing deployment around a shared repository prevents team members from overwriting changes made from separate laptops and makes the configuration behind running infrastructure easy to find. section 8.2.1 section 8.3

GitOps applies the pattern through four operating principles:

  • Declarative: express the desired system state as declarations rather than deployment steps. section 8.3
  • Versioned and immutable: store desired state with enforced versioning and a complete history. section 8.3
  • Pulled automatically: let software agents retrieve desired-state declarations from the source. section 8.3
  • Continuously reconciled: observe actual state and attempt to bring it back to the declared state. section 8.3

A centralized Terraform workflow

Alice and Bob commit infrastructure code to a shared Git repository instead of deploying independently from their laptops. An automated deployment system reads that repository and applies the configuration, allowing the repository to represent the infrastructure that should be running. section 8.2.1 section 8.3

The pattern also defines how to handle drift. When infrastructure changes outside the declared configuration, reconciliation detects the difference and attempts to restore the source-of-truth state. Terraform can detect and fix drift, but requires a larger system for reconciliation that runs beyond pull requests or merges, such as scheduled execution. section 8.3.2

How Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu covers it

How deep it goes
Defines four GitOps principles and explains drift reconciliation, but stops short of implementation configuration.
Examples
Uses shared Git repositories, Alice and Bob’s competing laptops, Terraform configuration, and scheduled drift correction.
What you can do after
Operate/configure centralized Terraform deployments from versioned declarations and restore infrastructure that drifts from them.
How it connects
Connects GitOps with Terraform, infrastructure as code, drift, continuous reconciliation, and centralized deployment.

Also explained in

Compare how 8 books explain source of truth →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu. The section links point to the parts of the book it draws on.