Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform 0.12 shows warnings only when there are changes #22541

Closed
cthulhu opened this issue Aug 21, 2019 · 4 comments · Fixed by #24095
Closed

Terraform 0.12 shows warnings only when there are changes #22541

cthulhu opened this issue Aug 21, 2019 · 4 comments · Fixed by #24095
Labels
bug cli v0.12 Issues (primarily bugs) reported against v0.12 releases

Comments

@cthulhu
Copy link

cthulhu commented Aug 21, 2019

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.
@hashibot hashibot added the v0.12 Issues (primarily bugs) reported against v0.12 releases label Aug 27, 2019
@wazcov
Copy link

wazcov commented Dec 18, 2019

+1

@nyurik
Copy link
Contributor

nyurik commented Feb 13, 2020

This is a serious bug, because some providers, e.g. Google, rely on this functionality - the 3.x upgrade guide:

Before upgrading to version 3.0.0, it is recommended to upgrade to the most recent 2.X series release of the provider, make the changes noted in this guide, and ensure that your environment successfully runs terraform plan without unexpected changes or deprecation notices.

Now I have to keep faking some changes just to show the deprecation warnings in terraform plan

nyurik added a commit to nyurik/terraform that referenced this issue Feb 13, 2020
Fixes hashicorp#22541

This change will print warnings, such as deprecations,
even if plan has no changes.
@nyurik
Copy link
Contributor

nyurik commented Feb 13, 2020

I hacked a fix #24095 for this bug, hopefully it would solve the problem for everyone.

@ghost
Copy link

ghost commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug cli v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants