-
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
Module depends_on #25005
Module depends_on #25005
Conversation
Connect references from depends_on in modules calls. This will "just work" for a lot of cases, but data sources will be read too early in the case where they require the dependencies to be created. While data sources will be properly ordered behind the module head node, there is nothing preventing them from being being evaluated during refresh.
verify a chain of depends_on references through modules execute in the correct order
Codecov Report
|
// run the plan again to ensure that data sources are not going to be re-read | ||
plan, diags := ctx.Plan() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something obvious, but I don't understand this comment. Why does re-planning after apply ensure that the data source isn't re-read?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the data source is read during plan (which is a new ability from #24904), it would show in the plan as a read operation. There should be nothing left to apply at this point, so anything in the plan should be NoOp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see now, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pulling this changeset down to put it through some paces on my machine, but in the meantime, looks like this doesn't include the docs if you want to add them here?
I've not delved deep into this yet because I don't have the necessary context loaded to think about the details, but I wanted to ask: could we make sure there's a test somewhere for the case where module The sort of test case I have in mind would be... root module: module "test" {
source = "./test"
a = module.test.b
}
output "c" {
value = module.test.c
} The variable "a" {}
resource "test" "test" {
}
output "b" {
value = test.test.id
}
output "c" {
value = var.a
} I would expect the above to work and for the root module output We have so many test fixtures in Terraform Core that I wouldn't be surprised if something like this was there somewhere already, but I'm not sure where it is if so. 😕 |
Good idea @apparentlymart! While I didn't expect that to be be effected by this PR, I want to make certain we have that test in the corpus. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having now had some extra time to familiarize myself with how the new "expand" nodes fit in with everything else 😄 this looks good to me! I did have a brief play with it to see how it looks and it matched what I was expecting, though I didn't have a deep play with it because @pselle already mentioned doing that. 😀
That this last change ended up being so straightforward and clear is, I think, a testament to all of the other refactoring work y'all have been doing these last few months. Good job! 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙄 I forgot to select "Approve" when I submitted that, though with that said I don't mean to override @pselle's comment about the docs. Hopefully it's a relatively straightforward docs update and so we could include that in here just to keep this change "atomic".
The docs change is minimal I think. I just have that in another PR since data sources also needed a |
I think this would be a big change (I mean a lot of codes need be updated), but not. That's amazing, thanks a lot. |
Thanks a lot for this feature. Looking forward to this release. |
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. |
Allow the use of
depends_on
for modules.This PR stands on the existing work already done for module expansion, evaluation, and data source planning. See #24461, #24697, and #24904 for the majority of the work involved in making that happen.
Now that modules can be ordered and referenced as a whole, and data sources will cleanly allow forced ordering by
depends_on
; all that is left is to enable the feature in the config and add the graph connections for thedepends_on
references.Closes #10462
Closes #17101