Terraform remote state and state locking
Why it matters
Local state means two people applying at once overwrite each other, and the state file — which holds secrets — lives on a laptop.
How to fix it
Configure a remote backend with locking:
terraform {
backend "s3" {
bucket = "my-tf-state"
key = "prod/terraform.tfstate"
region = "eu-central-1"
dynamodb_table = "tf-state-lock"
encrypt = true
}
}
Does your repository pass this check?
Free for public GitHub repositories, no account needed. 50+ DevOps and security checks in about ten seconds.