oreondev/terraform-production-checklist
About
A 36-line production checklist for Terraform, and tfchecklist, a CLI and GitHub Action that checks a repository against it
Systems & InfrastructureMeasured star growth
- in 24h
- Collecting history
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalTerraform production checklist
A 36-line checklist for Terraform in production, and tfchecklist, a small command-line tool that reads a repository and answers the lines that can be answered from files.
- CHECKLIST.md is the checklist itself: structure, state, versions, code quality, change process, drift, security and recovery.
tfchecklistchecks 23 of the 36 lines from the.tffiles, the pipeline definitions and the list of committed files. The other 13 are about how people work ("has a restore been tried?"), so it prints them as questions.
It reads files only. It does not run Terraform, does not need cloud credentials and makes no network calls.
Install
Ready-made programs for Linux, macOS and Windows (Intel/AMD and ARM) are on the releases page. They have no dependencies.
Linux and macOS:
os=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')
curl -fsSL -o tfchecklist "https://github.com/oreondev/terraform-production-checklist/releases/latest/download/tfchecklist_${os}_${arch}"
chmod +x tfchecklist && sudo mv tfchecklist /usr/local/bin/
Windows (PowerShell):
Invoke-WebRequest -OutFile tfchecklist.exe https://github.com/oreondev/terraform-production-checklist/releases/latest/download/tfchecklist_windows_amd64.exe
.\tfchecklist.exe -version
Each release has a checksums.txt with the SHA-256 of every file.
With Go 1.25 or later:
go install github.com/oreondev/terraform-production-checklist/cmd/tfchecklist@latest
Works with Terraform and OpenTofu code.
Use
tfchecklist # the current directory
tfchecklist path/to/repo
tfchecklist -format markdown > report.md
tfchecklist -format json | jq '.checks[] | select(.status == "FAIL")'
tfchecklist -skip 5.3,7.3 # leave out checks that do not apply to you
tfchecklist -list # the 36 checks and which are automatic
Part of a report:
2. State
FAIL 2.1 Remote state with locking
- envs/prod/main.tf:9 s3 backend without use_lockfile = true or a dynamodb_table: no locking
PASS 2.2 State encrypted at rest, access to the state store limited
Encryption is on or is the provider default. Who can read the state store is not visible in code: review that list by hand.
ASK 2.3 Nobody applies to production from a laptop
Is the pipeline the only identity that can apply to production?
Summary: 11 passed, 6 failed, 2 warnings, 13 to answer by hand, 4 not applicable
| Result | Meaning |
|---|---|
PASS |
The files show the check is met. A note says what still needs a look by hand. |
FAIL |
The files show it is not met. Each finding has a file and line. |
WARN |
A heuristic matched. Probably a problem, worth reading. |
ASK |
The answer is not in the repository. A person has to answer. |
N/A |
Does not apply, for example state checks in a repository that only holds modules. |
The exit status is 1 when a check fails (-fail-on warn also counts warnings, -fail-on never always exits 0) and 2 when the tool could not run.
GitHub Action
name: terraform-checklist
on: [pull_request]
jobs:
checklist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oreondev/[email protected]
with:
fail-on: fail # fail, warn or never
skip: "" # for example 5.3,7.3
The report is written to the job summary and the job log. The action downloads the release build for the runner (Linux, macOS or Windows, x64 or ARM64) and checks its SHA-256; if no build is available it compiles from source.
What it looks at
| Section | Checked from files | Asked |
|---|---|---|
| 1. Repository and structure | Environment switches inside a root, pinned module versions, module size, READMEs | Rule against manual changes |
| 2. State | Backend type and locking, encryption setting, resources that write secrets into state | Laptop applies, state backups and restore |
| 3. Providers and versions | required_version, provider constraints, committed lock file, Renovate or Dependabot, long-lived cloud keys in the pipeline |
Least privilege for the pipeline identity |
| 4. Code quality | fmt, validate, tflint and a scanner in the pipeline or pre-commit, variable types and descriptions, shared tags, hard-coded account IDs and regions in modules |
|
| 5. Change process | Plan on pull requests, approval before apply, cost estimate step, deletion protection on stateful resources | Rollback |
| 6. Drift and operations | Scheduled plan | Reconciling drift, imports, deprecations, plan times |
| 7. Security | Secrets in tfvars, defaults and committed state, sensitive outputs, policy files, modules that follow a branch | |
| 8. Recovery | Rebuild test, runbook, recovery plan |
Pipelines it reads: GitHub Actions, GitLab CI, Azure Pipelines, Bitbucket Pipelines, Jenkinsfile, CircleCI, Buildkite, Cloud Build, CodeBuild, Drone and a repository-level atlantis.yaml, plus .pre-commit-config.yaml for the code quality checks.
Limits
- It reads what is committed. A setting passed at
terraform inittime, a branch protection rule, an HCP Terraform workspace setting or a policy attached in the cloud is not visible, and the tool says so and asks. - Steps inside reusable workflows that live in another repository are not visible. Those checks are reported as
WARN. - Terragrunt
.hclfiles and.tf.jsonfiles are not parsed. - It does not look for insecure resources (open security groups, public buckets). Run checkov, trivy or a similar scanner for that; check 4.2 only confirms that one runs.
- The checks for secrets, tags and environment switches are pattern matches. They can miss things and they can be wrong. Secret values are never printed.
- A directory counts as a root module when it has a backend, a
cloudblock or aproviderblock. Directories underexamples,test,tests,testdataandfixturesare skipped.
Found a wrong result? Open an issue with the smallest snippet that shows it.
Development
go test ./...
go run ./cmd/tfchecklist testdata/bad
testdata/good meets every automatic check and testdata/bad fails most of them; the tests assert both.
Licence
Code: MIT. Checklist text: CC BY 4.0. Maintained by Oreon IT, who offer Terraform consulting. Overview, install and FAQ: oreonit.com/terraform-production-checklist.
Explore related projects
Loading…