Terraform

I explore how Terraform manages infrastructure by applying it to Docker containers and Kubernetes environments.

Categories:DevOpsSQL

A topic page: a summary of what my posts say, with each claim quoted from the post it came from. The posts are the authority. Last checked 2026-11-30.

Summary. I explore how Terraform manages infrastructure by applying it to Docker containers and Kubernetes environments. These posts demonstrate how Terraform maintains a state file to synchronize the real world with my configuration files.

What the posts say

The state file is the record of what Terraform created.

β€œThat file is Terraform's memory.” β€” Terraform on Your Laptop (Part 1)

A plan only reports what would happen and changes nothing.

β€œPlan changes nothing.” β€” Terraform on Your Laptop (Part 1)

The state still holds secrets, so the store needs protection.

β€œThe state is still a place for secrets.” β€” Terraform on Your Laptop (Part 6)

A resource deleted by hand is noticed at the next plan.

β€œThis is why people use Terraform instead of clicking: if someone changes or deletes something by hand, the next plan shows it.” β€” Terraform on Your Laptop (Part 1)

Scaling adds only the missing copies and leaves the running one alone.

β€œThe container already running was not touched.” β€” Terraform on Your Laptop (Part 2)

A data source reads something that exists and does not create it.

β€œA data source reads something that already exists and does not create it.” β€” Terraform on Your Laptop (Part 7)

A lock is not a transaction.

β€œA lock is not a transaction.” β€” Terraform on Your Laptop (Part 6)

A command run in the dev directory cannot change prod.

β€œA command run in environments/dev cannot change prod, because prod's resources are not in dev's state.” β€” Terraform on Your Laptop (Part 5)

The posts behind this page

  • Terraform on Your Laptop (Part 5) β€” Terraform environments on Kubernetes: dev, UAT and prod namespaces deployed from one shared module at pinned versions, with a change moving through UAT feedback to a release and a rollback.
  • Terraform on Your Laptop (Part 6) β€” Remote state and locking on a laptop, for the Kubernetes environments from Part 5: Terraform state moved from local files into PostgreSQL, one schema and one role per directory, tested with a lock clash, a refused credential, a killed apply and a teammate's fresh clone.
  • Terraform on Your Laptop (Part 7) β€” Five Terraform odds and ends, tried on the Kubernetes environments from the series: for_each instead of count, terraform test, a pipeline with an approval gate before prod, a data source that reads another directory's state, and terraform import.
  • Terraform on Your Laptop (Part 1) β€” I wrote one small Terraform file that pulls the public nginx image and runs it in Docker Desktop, then used plan, apply, a port change, a deleted container and destroy to see how Terraform works.
  • Terraform on Your Laptop (Part 2) β€” I put a small C# web site into Terraform on Docker Desktop, then changed the title, changed the code and scaled to three copies, and watched Terraform apply only what changed each time.
  • Terraform on Your Laptop (Part 3) β€” I added a SQL Server container to the C# web site with Terraform, wrote the database layer as T-SQL stored procedures, and watched what Terraform replaced, kept and refused to destroy.
  • Terraform on Your Laptop (Part 4) β€” Terraform and Kubernetes together: Terraform created a Kubernetes cluster and the objects in it, then I deleted pods, deleted a Deployment, scaled, rolled out new code and broke a copy to see who fixed what.