Skip to content

Terraform 0.12 shows warnings only when there are changes #22541

@cthulhu

Description

@cthulhu

Terraform Version

terraform version
Terraform v0.12.6

Terraform Configuration Files

main.tf

provider "null" {

}
resource "null_resource" "res" {
}

main.tfvars

test_var="12345"

Run

terraform init && terraform plan -var-file=main.tfvars

Expected Behavior

Warnings should be shown even if there are no changes.

Actual Behavior

Warnings are shown only when there are changes.

Steps to Reproduce

  1. terraform init
  2. terraform plan -var-file=main.tfvars

Changes and warnings are shown

  1. terraform apply -var-file=main.tfvars -auto-approve
  2. terraform plan -var-file=main.tfvars

No changes, no warnings

Additional Context

After migration to terraform 0.12 we saw stricter behavior and warnings we would like to address, but we see them only when there are changes. So we have to create a change artificially in order to fix those recommendations.

Example of the warning:

Warning: Value for undeclared variable

  on main.tfvars line 1:
   1: test_var="12345"

The root module does not declare a variable named "test_var". To use this
value, add a "variable" block to the configuration.

Using a variables file to set an undeclared variable is deprecated and will
become an error in a future release. If you wish to provide certain "global"
settings to all configurations in your organization, use TF_VAR_...
environment variables to set these instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions