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

Output variables populated from data.external data sources are never populated causing errors #16728

Closed
JBirdVegas opened this issue Nov 21, 2017 · 2 comments

Comments

@JBirdVegas
Copy link

JBirdVegas commented Nov 21, 2017

After upgrading to 0.11 we started having deployments fail.

When the result of an external data source is used to populate an output variable terraform fails.

Terraform Version

Terraform v0.11.0
+ provider.external v1.0.0
+ provider.null v1.0.0

Terraform Configuration Files

Simplest example I could come up with to illustrate the problem. Note if you move the python code to it's own file the result will be the same. The external datasource will not be executed but the output's depending on the datasource will fail validation.
https://gist.github.com/JBirdVegas/9e508d2ce4266fd7c242c3f080f5368f

Debug Output

https://gist.github.com/JBirdVegas/97d8fc110a353c6db6b199eae655714b

Expected Behavior

Output variable should be populated after external datasource can be evaluated

Actual Behavior

Terraform appears to attempt to validate the output variable before evaluating the external datasource that should be a parent module

Steps to Reproduce

$ terraform init
$ terraform plan

Important Factoids

Seems like this kinda thing should have first turned into a warning before terraform started breaking deployments with no way of going back to a previously working version of terraform.

Edit:
Reported remedies do not work for this provider. Example adding the following the the script provided

output "result_of_python_test" {
  value = "${join("", data.external.test_python.result.*.status)}"
}
output "result_of_python_test_2" {
  value = "${join("", data.external.test_python.*.result.*.status)}"
}
output "result_of_python_test_3" {
  value = "${join("", data.external.test_python.*.result.status)}"
}

will return these errors:

Error: Error running plan: 3 error(s) occurred:

* output.result_of_python_test_2: Resource 'data.external.test_python' does not have attribute 'result.*.status' for variable 'data.external.test_python.*.result.*.status'
* output.result_of_python_test: Resource 'data.external.test_python' does not have attribute 'result.*.status' for variable 'data.external.test_python.result.*.status'
* output.result_of_python_test_3: Resource 'data.external.test_python' does not have attribute 'result.status' for variable 'data.external.test_python.*.result.status'

References

@jbardin
Copy link
Member

jbardin commented Nov 21, 2017

Hi @JBirdVegas,

While this particular instance would have been hidden by the silent output errors, this is a slightly different case as it wouldn't be valid anywhere in the config. The depends_on in the data source is forcing it to not be evaluated in time for the interpolation.

We're tracking that issue in #11806.

@ghost
Copy link

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

No branches or pull requests

2 participants