-
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
Allow better control over targeted apply. #26812
Comments
What you're describing is exactly what --target does
If you think this is unachievable in your current project, then you have a process problem. It is not only achievable to get to the point where 100% of your changes go through terraform, it is also fairly easy to get to that point, with enough buy-in from the business, and enough drive from the developers. |
I've seen more than a few cases where --target does not work that way. One I even had to work around today where running (Sorry for the door stopper of a response, but you touched on a meta-concept that's a bit of a soapbox of mine.) Regarding having 100% of stuff go through TF; I would like you to be correct, but:
As for reasons that "it's not feasible to manage all infra changes through terraform"; some of them include:
Basically all of those are solved or massively mitigated by treating a TF config as aspirational; as the end goal, and give terraform the feature set to allow the user to use it to move towards that goal in whatever controlled manor they deem best. Right now I can accomplish that, but the "feature set" mostly consist of abusing the tools: modifying the config to make it match the parts of reality I can't yet fix (with no intent of ever committing that), breaking spurious dependencies via |
Current Terraform Version
0.13
Use-cases
During development or operation processes, it's not uncommon for reality to diverge from the associated TF config and, even when the config is the desired end state, it is often not possible move directly from the current state to that ends state. For example, there may be cases where ACLs are temporarily and/or experimentally modified in an effort to address an active incident. It may then be necessary to make updates to some of the resource in the TF config while leaving other parts divergent. For example, updating the things that ACL tweak is protecting so it can be tested before the ACL tweak is removed. Currently there are approximately three options on how to do this:
--target=
can be used.plan
shows they match what it would do.Case 1 only works in some cases. Cases 2 &3 are far from convenient.
Preemptive comment: the way that terraform and it's documentation is set up, it looks to me like the way the terraform developers expect it to be used in this case is that the hypothetical ACL change (and in fact 100% of changes) would have originally been done via TF. While I like that as an ideal, it's a rather Utopian restriction that don't match well with reality. As soon as there are things not managed by TF (or managed by TF configs that are made inaccessible by their owners) that falls apart. It also falls apart during the process of migrating things into TF. And when constraints outside the reach of TF's control intrude.
In short: it is unavoidable that terraform will have to interact with other sources of change and can not always do so by just overwriting them. [end rant]
Proposal
Add a flag, like
--target=
, but where only the listed resource will be updated. An un-listed resource will be left in a divergent state or, where that's not possible (e.g. the dependent resource or attribute does not yet exist), cause an error.The text was updated successfully, but these errors were encountered: