Keep it modular
Break infrastructure into reusable modules — networking, compute, storage — each with clear inputs and outputs.
Use remote state
Store state in a backend like S3 with locking via DynamoDB so your team never overwrites each other.
terraform {
backend "s3" {
bucket = "my-tf-state"
key = "prod/terraform.tfstate"
region = "us-east-1"
}
}
Other habits
- Pin provider versions.
- Run
terraform fmtandvalidatein CI. - Never hard-code secrets — use variables and a secret manager.