-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Generalize target addresses before expansion #25760
Conversation
Codecov Report
|
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.
The resource change makes sense to me. I have a question about targeting a module instance, but it's an aside and needn't block merge ✅
case addrs.AbsResourceInstance: | ||
targetAddr = instance.ContainingResource().Config() | ||
case addrs.ModuleInstance: | ||
targetAddr = instance.Module() |
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 was curious about why the module case was removed here, and tried to check if targeting a module instance would work. It doesn't seem to (unless my test is broken), and I couldn't find a way to make it work, but I'm very unfamiliar with this code so that's not surprising.
Should terraform apply -target=module.mod[1]
work? Does it already and I'm just mistaken?
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.
Thanks @alisdair! It appears I was thinking about this block in terms of only resource addresses (probably because of the case statement), and not the module itself. Let me add some tests in here too, since that was obviously not covered.
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.
✅ 2️⃣
Before expansion happens, we only have expansion resource nodes that know their ConfigResource address. In order to properly compare these to targets within a module instance, we need to generalize the target to also be a ConfigResource. We can also remove the IgnoreIndices field from the transformer, since we have addresses that are properly scoped and can compare them in the correct context.
When working with a ConfigResource, the generalization of a ModuleInstance to a Module was inadvertently dropped, and there was to test coverage for that type of target. Ensure we can target a specific module instance alone.
cc766aa
to
b9e076e
Compare
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. |
Before expansion happens, we only have expansion resource nodes that
know their ConfigResource address. In order to properly compare these to
targets within a module instance, we need to generalize the target to
also be a ConfigResource.
We can also remove the IgnoreIndices field from the transformer, since
we have addresses that are properly scoped and can compare them in the
correct context.
Fixes #25748