-
Notifications
You must be signed in to change notification settings - Fork 1.2k
If the target supplied by --target does not exist, opentofu exits 0 #3729
Description
Community note
Tip
👋 Hi there, OpenTofu community! The OpenTofu team prioritizes issues based on upvotes. Please make sure to upvote this issue and describe how it affects you in detail in the comments to show your support.
OpenTofu Version
OpenTofu v1.11.4
on darwin_arm64OpenTofu Configuration Files
resource "null_resource" "real_resource" {
...
}Debug Output
N/A
Expected Behavior
I expect OpenTofu to fail if any resource specified in --target does not exist and take no action at all.
Actual Behavior
OpenTofu does nothing and exits 0.
Steps to Reproduce
tofu apply --target null_resource.fake_resource
Additional Context
I know behavior changes like this are always controversial.
We have a use case where we specify a very large number of targets.
If any of these do not exist, something has gone wrong and tofu should not continue. I can't imagine a scenario when this isn't the case. I'm sure someone has some strange edge case they have built off this behavior though (threads like this always surface a few).
References
No response
Thanks for confirming, @johnbarney! The maintainers discussed this today and have accepted the compromise I described in #3729 (comment).
This issue therefore now represents changing the plan output so that it produces the modified "No changes" message whenever all of the mentioned heuristics apply. This then serves as a hint to the operator that their use of -target might be the cause of an unexpectedly-empty plan.
We will also look for opportunities to handle this more precisely as the main language runtime implementation evolves in future, but any work in that vein is outside the scope of this issue and would instead be discussed as part of whatever later project would improve the feas…