Replies: 2 comments 2 replies
|
Hi @Jougan-0, The "target" and "exclude" functions are more intended for situations where your valid configuration would not be plannable or applyable because something outside of OpenTofu is broken, such as the remote API associated with one of the providers having an outage and you needing to make changes to compensate for that outage. Can you say more about what situations cause you to need to plan with an invalid configuration? I'd like to understand in more detail what you're trying to do since there is certain work we need to do in order for any expression evaluation to be possible at all, but depending on what you're asking about there might be a way to narrowly avoid it if it seems like something that would be broadly useful enough to justify the additional complexity. |
|
Hey @apparentlymart example I have a large configuration, a few hundred resources, and I often only want to plan or apply a small part of it with -target. Occasionally a few resource blocks elsewhere in the configuration end up invalid for reasons unrelated to the part I'm working on. Examples are two arguments set together that can't be combined, an attribute that a newer provider version treats as read-only, or a reference to a resource that isn't declared. I fix those when I get to them, but until then one invalid block anywhere stops me from planning or applying the handful of resources I targeted, even though those resources and their dependencies are valid. To try this out locally, I skipped the whole-configuration Validate call in localRun behind an environment variable. As far as I can tell the targeted resources still get validated:
So the only difference is that resources outside the targeted graph aren't checked. I am not sure tbh if this is a valid case but I know that plan runs validate independently on selected resources so why run it on the whole file if I am using target. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Currently, tofu plan -target performs implicit configuration validation, including resources outside the targeted scope.
For example, if a configuration contains 100 resources and 10 unrelated resources have errors, those errors may prevent planning or applying an otherwise healthy resource.
Since tofu plan already performs validation internally, could that validation be limited to the targeted resource and its dependency graph when -target is specified?
Would it be feasible to skip semantic validation of unrelated resources while still enforcing necessary syntax, provider, and dependency checks?
Curious to hear the maintainers' thoughts on the feasibility, architectural limitations, and potential trade-offs.
All reactions