Skip to content
Aesthetic Infra
    • EN
    • VI — This article is not available in this language

    Terraform state for small teams

    Hieu Vu

    1 min read
    On this page

    Terraform state maps your configuration to real resources. Losing it, or editing it concurrently, is how small teams end up with orphaned infrastructure.

    Store state remotely

    backend.tf
    terraform {
      backend "s3" {
        bucket       = "my-team-tfstate"
        key          = "prod/terraform.tfstate"
        region       = "ap-southeast-1"
        use_lockfile = true
      }
    }

    Lock every run

    Locking prevents two terraform apply runs from writing state at the same time.

    Written by

    Hieu Vu

    Software engineer writing about cloud infrastructure, DevOps and reliable systems.