The terraform command detects TF_VAR_* environment variables used in your Terraform configurations and verifies they exist in your .env files.
envcheck terraform . --env .env
envcheck terraform infra/ --env .env.prod
Terraform allows setting variables via environment variables with the TF_VAR_ prefix:
# variables.tf
variable "database_url" {
type = string
}
# .env
TF_VAR_database_url=postgres://localhost:5432/db
envcheck scans your .tf files for variable declarations and ensures matching TF_VAR_* entries exist in your .env.
$ envcheck terraform infra/ --env .env
Scanning infra/variables.tf
W007: Variable 'api_key' declared but TF_VAR_api_key missing in .env
W008: TF_VAR_legacy_token in .env but no matching variable declaration
Found 2 issues
- uses: envcheck/action-envcheck@v1
with:
command: terraform
args: "infra/"
env_file: ".env"