-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Computed module output is not forcing new on dependent resource #25015
Comments
@jcarlson this is a really well written issue report. Thanks! I need confirmation from @jbardin but I believe that the cause of this is that data sources are currently evaluated first, and are not part of the graph. Fortunately, @jbardin is making v0.13.0-targeted changes to have module data sources participate in the graph, so that module |
@danieldreier Thanks! After I submitted the issue, I went hunting for related issues. I couldn't believe that no one else had run into this issue. Indeed, #17034 does appear to explain the root cause in much more gory detail than I have here. Still, it was interesting that flattening the structure of the project seemed to resolve the issue. According to the information in #17034, I would not have expected that to be the case. |
Yes, this is fixed by #24904, which allows data sources to be re-evaluated during plan. As for why flattening the config works in this case, there was check in place to catch this type of relationship in the simplest case, which is when the data source directly referenced another resource. |
@jcarlson I'm going to resolve this because it's fixed in 0.13 and the beta for that comes out next week. Thanks for reporting it and I'm glad we had a fix already in the works! |
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. |
Terraform Version
Terraform Configuration Files
Expected Behavior
Changing the value of the
name
variable for modulefoo
should causemodule.foo.null_resource.resource_in_module
andnull_resource.resource_in_root
to both be replaced in one execution ofterraform apply
.Actual Behavior
Changing the value of the
name
variable for modulefoo
causes onlymodule.foo.null_resource.resource_in_module
to be replaced; you must runterraform apply
a second time in order for Terraform to detect and replacenull_resource.resource_in_root
.Steps to Reproduce
terraform init
terraform apply
name
on modulefoo
in the rootterraform plan
module.foo.null_resource.resource_in_module
is marked for replacementAdditional Context
I have observed this on a couple of different resource and data types. This was the simplest configuration that exhibited this behavior.
If you were to flatten the project structure so that all data and resource blocks were in the root, and no modules were in use, then everything would work as expected. So the issue here is with the way that module outputs are used as inputs to data sources.
The dependency graph generated here seems to suggest that the dependencies are properly recognized, but somewhere, when the output of a module is used as the input to a data resource, and that output is computed and/or is known to change, that seems to be lost in translation.
For example, the following structure resolves this issue:
References
The text was updated successfully, but these errors were encountered: