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

Undefined data value silently ignored in 0.7 #7722

Closed
WolverineFan opened this issue Jul 20, 2016 · 3 comments
Closed

Undefined data value silently ignored in 0.7 #7722

WolverineFan opened this issue Jul 20, 2016 · 3 comments

Comments

@WolverineFan
Copy link
Contributor

I was playing around with the suggestions in #4084 and specifically the last comment with mentions the new null_data_source (#6717) and noticed this problem. It also happened when I tried to use
data "terraform_remote_state" "network"
so I don't think it's specific to null_data_source. Essentially what happens is the output that tries to use an undefined piece of data fails to show up silently. If I do the same thing with a resource or variable it fails with a good error.

Terraform Version

Terraform v0.7.0-rc3 (3f4857a)

Affected Resource(s)

Looks like a core issue with data.* references

Terraform Configuration Files

variable "test1" {
  default = "foo"
}

output "test1" {
  value = "${var.test1}"
}

data "null_data_source" "test2" {
    inputs = {
        myval = "${var.test1}bar"
        myval2 = "${var.test1}bar2"
    }
}

output "test2myval" {
  value = "${lookup(data.null_data_source.test2.inputs,"myval")}"
}

output "test2invalid1" {
  value = "${lookup(data.null_data_source.test2.inputs,"notthere")}"
}

output "test2invalid2" {
  value = "${data.null_data_source.test2.inputs.notthere}"
}

output "test2all" {
  value = "${data.null_data_source.test2.inputs}"
}

Expected Behavior

And error of some sort for test2invalid1 and test2invalid2

Actual Behavior

Outputs:

test1 = foo
test2all = {
  myval = foobar
  myval2 = foobar2
}
test2myval = foobar

Steps to Reproduce

  1. terraform apply

References

@WolverineFan WolverineFan changed the title Undefined data value silently ignored in 0.7-rc3 Undefined data value silently ignored in 0.7 Aug 12, 2016
@WolverineFan
Copy link
Contributor Author

Looks like this is still happening in 0.7.7. I noticed when running with TF_LOG=1 that there's a warning being printed. Would it be a problem to convert that to an error?

2016/10/25 11:55:46 [DEBUG] Interpolating computed map element attribute inputs (2)
2016/10/25 11:55:46 [WARN] Output interpolation "test2invalid2" failed: Resource 'data.null_data_source.test2' does not have attribute 'inputs.notthere' for variable 'data.null_data_source.test2.inputs.notthere'
...
2016/10/25 11:55:46 [DEBUG] Interpolating computed map element attribute inputs (2)
2016/10/25 11:55:46 [WARN] Output interpolation "test2invalid1" failed: lookup: lookup failed to find 'notthere' in:

${lookup(data.null_data_source.test2.inputs,"notthere")}

@mitchellh
Copy link
Contributor

Dup of #5334 where we've centralized this issue.

@ghost
Copy link

ghost commented Apr 20, 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 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants