DevOps Peach

Advanced Terraform · Module 02

State and Teamwork

Understand what the state file holds and why it is sensitive, move it to a remote S3 backend with locking (on LocalStack), refactor addresses with moved and removed blocks instead of destroying, and split large states while sharing outputs safely.

Practice interactively →

What you will learn

Lessons

  1. Inside the State File

    State maps every resource address in your code to a real object ID; it stores all attributes in plain text, including secrets, and is protected by serial and lineage.

  2. Remote Backends and State Locking

    A backend stores state remotely; the S3 backend locks with a .tflock object (use_lockfile), takes environment-specific settings through partial configuration and migrates local state with init.

  3. Refactoring: moved, removed and state Commands

    Rename or move resources without destroying them using moved blocks or terraform state mv, and stop managing something without deleting it using removed blocks or terraform state rm.

  4. Splitting State and Sharing Outputs

    Split one big state into layers with a small blast radius, then pass values between them through outputs, terraform_remote_state or, better, data sources.