Interview Prep/Terraform/State Internals

How do you configure the S3 backend?

BeginnerConceptState Internals
Answer
terraform {
  backend "s3" {
    bucket       = "acme-tfstate-prod"
    key          = "network/terraform.tfstate"
    region       = "ap-south-1"
    encrypt      = true
    use_lockfile = true
  }
}

Then run terraform init. Enable bucket versioning, block public access and restrict IAM to the CI role.

All Terraform questions Roadmap: Terraform in production

More on State Internals