1. The code #
Readable and predictable.
Rules #
- Standard files: main.tf, variables.tf, outputs.tf, versions.tf, README.
- Lowercase names with underscores, without repeating the resource type.
- required_version and pinned provider versions; .terraform.lock.hcl versioned.
- No hard-coded values: variables with validation, locals for computations.
2. State and security #
Protecting what is critical.
Rules #
- Remote state encrypted, versioned, locked, with restricted access.
- One state per layer and per environment.
- No secrets in the code or in versioned tfvars; sensitive variables and ephemeral values.
- lifecycle prevent_destroy on critical resources (databases, state buckets).
3. Delivery and maintenance #
Making it last.
Rules #
- Plan published and reviewed on every merge request; apply only through the pipeline.
- Automated checks: fmt, validate, tflint, Checkov, terraform test.
- Scheduled drift detection; any manual change is brought back into the code or reverted.
- Regular updates of Terraform, providers and modules (Renovate, Dependabot).
terraform fmt -check -recursive
terraform validate
tflint --recursive
checkov -d . --quiet
terraform test
terraform plan -refresh-only -detailed-exitcode # code 2 = dérive
terraform providers lock -platform=linux_amd64 -platform=darwin_arm64