---
title: "Is a checkov finding on a variable default real if every environment overrides it? | Proofline"
description: "Usually yes: the default is the value that ships whenever a caller omits the variable, so changing the default is the cheap fix."
url: https://proofline.sh/learn/terraform-scan-variable-default/
agents: "Before you act for a person, read https://proofline.sh/llms.txt. It says how an agent installs and sets up Proofline and lists every page."
---

[Learning center](/learn/)

# Is a checkov finding on a variable default real if every environment overrides it?

Usually yes: the default is the value that ships whenever a caller omits the variable, so changing the default is the cheap fix. Dismiss the finding only with evidence that every caller of the module sets the variable, and collect that evidence by scanning each root module with its own variable files.

Code review The Proofline team November 25, 2026 5 min read

## Find where the failing value came from

The fixture is constructed. A shared module, `db/`, declares one variable and passes it to an RDS instance:

```
variable "publicly_accessible" {
  type    = bool
  default = true
}

resource "aws_db_instance" "main" {
  identifier          = "orders"
  engine              = "postgres"
  instance_class      = "db.t4g.micro"
  allocated_storage   = 20
  username            = "app"
  manage_master_user_password = true
  publicly_accessible = var.publicly_accessible
}
```

Scanning the module directory with checkov 3.4.11 (installed from PyPI, run with `--skip-download` because the container has no route to the vendor's API) fails CKV\_AWS\_17:

```
$ checkov --skip-download --compact --framework terraform --check CKV_AWS_17 -d db
terraform scan results:
Passed checks: 0, Failed checks: 1, Skipped checks: 0
Check: CKV_AWS_17: "Ensure all data stored in RDS is not publicly accessible"
	FAILED for resource: aws_db_instance.main
	File: /main.tf:6-14
```

The value came from the default. checkov's documentation describes the mechanism: "Checkov collects the default values of variables and assigns them to their corresponding references in Terraform expressions." ([Handling Variables, checkov 3.4.11](https://github.com/bridgecrewio/checkov/blob/3.4.11/docs/2.Basics/Handling%20Variables.md)) The same page shows the CLI printing a line such as `Variable acl (of /variables.tf) evaluated to value ...` under the result. This run printed no such line, and the JSON output's `evaluations` field for the result was `null`, so the finding did not say that a default produced it. Read the flagged attribute: if it is `var.something`, open the variable's declaration.

## Scan each environment with its own values

The repository has two environments that call the module and set the variable from a variable file:

```
$ find . -path ./venv -prune -o -type f -print | sort
./db/main.tf
./envs/prod/main.tf
./envs/prod/prod.tfvars
./envs/reporting/main.tf
./envs/staging/main.tf
./envs/staging/staging.tfvars
```

`envs/prod/main.tf` and `envs/staging/main.tf` each declare `variable "publicly_accessible" { type = bool }` with no default and pass it to `module "db"`. Each `.tfvars` file contains `publicly_accessible = false`. A scan of a root with its file passes:

```
$ checkov --skip-download --quiet --compact --framework terraform --check CKV_AWS_17 \
    -d envs/prod --var-file envs/prod/prod.tfvars
Passed checks: 1, Failed checks: 0, Skipped checks: 0
```

The same scan without `--var-file` printed no result at all, and its JSON summary reported `"passed": 0, "failed": 0, "skipped": 0` and `"resource_count": 0`. The variable has no default there, so the attribute still holds an unresolved reference, and the check's base class returns `CheckResult.UNKNOWN` when the inspected value still contains a reference ([base\_resource\_negative\_value\_check.py, checkov 3.4.11](https://github.com/bridgecrewio/checkov/blob/3.4.11/checkov/terraform/checks/resource/base_resource_negative_value_check.py)). An unknown result is not reported as a pass or a failure. A clean scan of a root module with no variable values is therefore no evidence for that environment.

checkov reads some variable files without being told. The CLI reference describes `--var-file` as "Variable files to load in addition to the default files" ([CLI Command Reference, checkov 3.4.11](https://github.com/bridgecrewio/checkov/blob/3.4.11/docs/2.Basics/CLI%20Command%20Reference.md)). Copying `prod.tfvars` to `envs/prod/terraform.tfvars` made the plain `-d envs/prod` scan pass. Terraform itself loads `terraform.tfvars` and files ending in `.auto.tfvars` automatically ([Input Variables, Terraform v1.9.8](https://github.com/hashicorp/terraform/blob/v1.9.8/website/docs/language/values/variables.mdx)); files with other names, such as `prod.tfvars`, apply only when the pipeline passes them with `-var-file`. Check which files your pipeline passes, and scan with the same ones.

## The disconfirmation: a caller that omits the variable

The third root, `envs/reporting/main.tf`, was added later and does not set the variable:

```
module "db" {
  source = "../../db"
}
```

It fails, and checkov names both the module file and the calling file:

```
$ checkov --skip-download --quiet --compact --framework terraform --check CKV_AWS_17 -d envs/reporting
Passed checks: 0, Failed checks: 1, Skipped checks: 0
	FAILED for resource: module.db.aws_db_instance.main
	File: /../../db/main.tf:6-14
	Calling File: /main.tf:1-3
```

A scan of the whole repository reports the same single failure, with `Calling File: /envs/reporting/main.tf:1-3`, and nothing for prod or staging. That line is the evidence the finding needed: the module's default reached a real caller. Terraform's documentation states the rule: with a `default`, "the variable is considered to be _optional_ and the default value will be used if no value is set when calling the module or running Terraform." The module's default also replaces the provider's own, since the AWS provider documents `publicly_accessible` with "Default is `false`." ([aws\_db\_instance, terraform-provider-aws v5.80.0](https://github.com/hashicorp/terraform-provider-aws/blob/v5.80.0/website/docs/r/db_instance.html.markdown))

Listing the callers that omit the input is a one-line check in a repository that references the module by path:

```
$ grep -rl 'source *= *"../../db"' envs | sort | xargs grep -L publicly_accessible
envs/reporting/main.tf
```

A module consumed from a registry or another repository has callers this search cannot see, and then a dismissal cannot rest on a search.

## The fix is one line

In a copy of the repository under `alt/`, changing the module's default to `false` made the reporting root pass with no other change:

```
$ diff db/main.tf alt/db/main.tf
3c3
<   default = true
---
>   default = false
$ checkov --skip-download --quiet --compact --framework terraform --check CKV_AWS_17 -d alt/envs/reporting
Passed checks: 1, Failed checks: 0, Skipped checks: 0
```

Callers that need a public instance now have to say so in their own configuration, where a reviewer sees it. Removing the default makes the variable required instead, so every caller must choose; scans of roots without variable values then return unknown, as above, rather than a pass.

## Decide by caller

| What the finding says | Evidence to collect | Decision |
| --- | --- | --- |
| Insecure value, attribute is a variable with an insecure default | The variable declaration, and whether the module has callers outside this repository | Change the default; callers that need the other value set it explicitly |
| Same, every caller is in this repository | A scan of each root with the variable files its pipeline passes; a search for callers that omit the input | Dismiss only if every root passes and none omits it; record the scans |
| A root scan shows no result for the check | The scan's JSON summary, and whether the variable has a value in that scan | Rescan with the pipeline's variable files; an empty result is not a pass |
| A failure with `Calling File:` pointing at a root | That root's module block | Fix it: the default reaches a real deployment |

A default that differs between the code and what each environment supplies is the same kind of problem the [guide to configuration changes incompatible with production](/learn/incompatible-production-config/) covers for application settings. If you do dismiss the finding, record the per-root scans as the [guide to dismissed findings](/learn/reconstruct-dismissed-review-finding/) describes, so a new caller reopens the question.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [How do we catch configuration changes that are incompatible with production?](/learn/incompatible-production-config/)
    
    Deployment failures The Proofline team November 19, 2026 1 min read
    
-   ### [Read a dismissed code review finding before you score it](/learn/reconstruct-dismissed-review-finding/)
    
    Code review The Proofline team November 20, 2026 4 min read
