IaC & Terraform
Ecosystem

terraform --help

Filterable reference for the Terraform toolchain: validate, plan, security scanning, cost estimation, state surgery, and docs.

14 tools
6 phases
Terraform 1.x, OpenTofu, AWS
Phase 14 tools shown
ToolPhaseKey commandsUse case
terraform fmt / validate validate
terraform fmt -recursive -diff terraform fmt -check -recursive terraform validate terraform validate -json | jq '.diagnostics[]'
Format and validate HCL before anything else. -check exits non-zero for CI gating. validate catches provider schema errors without hitting the API.
tflint validate
tflint --init tflint --recursive tflint --format compact tflint --var-file=prod.tfvars tflint --enable-rule=terraform_unused_declarations
Provider-aware linting beyond validate: catches deprecated resource arguments, invalid instance types, missing required tags. Uses ruleset plugins per provider.
tfenv validate
tfenv list-remote tfenv install 1.8.5 tfenv use 1.8.5 echo "1.8.5" > .terraform-version tfenv install # reads .terraform-version
Pin and switch Terraform versions per repo. .terraform-version committed to the repo ensures CI and local use identical binaries.
terraform plan plan
terraform plan -out=tfplan terraform plan -var-file=prod.tfvars -out=tfplan terraform plan -target=aws_instance.web terraform plan -refresh=false terraform show -json tfplan | jq '.resource_changes[] | select(.change.actions[] | contains("delete"))'
Always save plan to file for apply; parse JSON output to audit deletes before applying in prod. -refresh=false skips API calls when speed matters.
terragrunt plan
terragrunt run-all plan terragrunt run-all apply --terragrunt-non-interactive terragrunt run-all destroy --terragrunt-non-interactive terragrunt plan --terragrunt-log-level debug terragrunt validate-inputs
DRY wrapper for multi-account/multi-region stacks. run-all handles dependency ordering across modules. validate-inputs catches missing vars early.
terraform-plan-summary plan
terraform show -json tfplan | jq -r ' .resource_changes[] | "\(.change.actions | join(","))\t\(.address)"' | sort | column -t # count changes by action type terraform show -json tfplan | jq ' [.resource_changes[].change.actions[]] | group_by(.) | map({(.[0]): length}) | add'
No extra tool needed: terraform show -json + jq gives a terse change summary. Useful in CI PR comments without installing additional binaries.
trivy (IaC mode) security
trivy config . trivy config --severity HIGH,CRITICAL . trivy config --format json . | jq '.Results[].Misconfigurations[]' trivy config --tf-vars prod.tfvars . trivy config --exit-code 1 --severity CRITICAL .
Static misconfiguration scanning across Terraform, CloudFormation, Helm, Dockerfile in one tool. Use --exit-code 1 as a CI gate on CRITICAL findings.
checkov security
checkov -d . checkov -d . --framework terraform --check CKV_AWS_20 checkov -d . --skip-check CKV_AWS_79 checkov -d . -o json | jq '.results.failed_checks[].check_id' checkov --list # all available checks
Policy-as-code for Terraform/CF/K8s/ARM. Broader check library than trivy; supports custom Python checks. Integrates with Prisma Cloud if needed.
conftest / OPA security
terraform show -json tfplan > tfplan.json conftest test tfplan.json -p policy/ conftest test tfplan.json -p policy/ --all-namespaces conftest pull github.com/open-policy-agent/library opa eval -d policy/ -i tfplan.json "data.terraform.deny"
Write Rego policies against the Terraform plan JSON: enforce naming conventions, tag requirements, banned resource types, region restrictions. Version-controlled, auditable.
infracost cost
infracost breakdown --path . infracost breakdown --path . --format json | jq '.totalMonthlyCost' infracost diff --path . --compare-to infracost-base.json infracost breakdown --path . --terraform-var-file prod.tfvars infracost comment github --path infracost.json --pull-request $PR_NUMBER --repo $REPO
Cost estimate from Terraform plan before apply. diff shows delta vs baseline: essential for PR reviews on infra changes. GitHub comment integration posts the diff automatically.
terraform state state
terraform state list terraform state show aws_instance.web terraform state mv aws_instance.old aws_instance.new terraform state rm aws_s3_bucket.legacy terraform state pull > backup.tfstate terraform state push backup.tfstate
State surgery: rename resources after refactoring, remove orphans, back up before destructive operations. Always pull a backup before any mv or rm.
terraform import / refresh state
terraform import aws_s3_bucket.main my-bucket-name terraform import 'aws_security_group_rule.ingress[0]' sg-id_tcp_8080_8080_0.0.0.0/0 terraform apply -refresh-only terraform apply -refresh-only -target=aws_instance.web
Import existing cloud resources into state without recreating them. -refresh-only syncs state to real-world without making changes: safe drift detection.
tfmigrate state
tfmigrate plan migration.hcl tfmigrate apply migration.hcl # migration.hcl example: # migration "state" "mv_instance" { # actions = ["mv aws_instance.old aws_instance.new"] }
Version-controlled, reviewable state migrations. Declarative HCL replaces ad-hoc state mv sequences: safe for team environments and auditable in PRs.
terraform-docs docs
terraform-docs markdown . > README.md terraform-docs markdown table . terraform-docs json . # inject into existing README between markers: terraform-docs markdown . --output-file README.md --output-mode inject # .terraform-docs.yml for per-module config
Auto-generate inputs/outputs/requirements docs from module code. inject mode preserves hand-written content around generated blocks. Run in CI to keep docs current.
No tools match this filter.