Skip to content
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

Feature request: add an option to skip terraform plan-ing #142

Closed
mdb opened this issue Aug 3, 2023 · 4 comments
Closed

Feature request: add an option to skip terraform plan-ing #142

mdb opened this issue Aug 3, 2023 · 4 comments

Comments

@mdb
Copy link
Contributor

mdb commented Aug 3, 2023

👋 Thanks for your work on tfmigrate -- the tool is really useful. I'd love the ability to configure whether tfmigrate performs terraform plans under the hood, especially during multi_state operations. I'm imagining something like:

migration "multi_state" "mv_local_file_bar" {
  from_dir            = "project-one"
  from_terraform_plan = false

  to_dir            = "project-two"
  to_terraform_plan = true # default behavior

  actions = [
    "mv local_file.bar local_file.bar",
  ]
}

More context

As for my use case, imagine the following scenario...

My team's project-one Terraform project is excessively monolithic and manages thousands of resources. As such, its terraform plan and terraform apply each take hours to complete. To fix this, I want to use tfmigrate to piecemeal and incrementally migrate project-one resources into more appropriately granular projects, like project-two. However, because tfmigrate performs a terraform plan against project-one with each tfmigrate plan and each tfmigrate apply -- and because terraform plan-ing project-one takes hours -- each tfmigrate action takes a prohibitively long time.

In this case, I'd like to disable tfmigrate from plan-ing project-one. As such, I'm willing to accept the risks of bypassing the terraform plan diff analysis in favor of faster feedback and tfmigrate actions that don't take a prohibitively long time to complete.

@minamijoyo
Copy link
Owner

Hi @mdb, Thank you for your proposal!

There was a similar proposal to skip planning in #53 previously, but the use case seems slightly different. Of course, we prefer not to skip planning as much as possible, but I understand that it is sometimes inevitable to solve practical problems. I do not intend to implement this feature myself, but I am open to accepting it if someone does.

About the name of the attribute, I prefer the attribute name from_skip_plan; its default value should be false because if there are more flags to customize plan behavior in the future, it would be unclear what from_terraform_plan=false means.

@mdb
Copy link
Contributor Author

mdb commented Aug 4, 2023

Hi @minamijoyo ! Thanks for the response! (And, philosophically, I'm also wary of the plan-skipping, despite my real-world pragmatic interest in doing so in some circumstances. However, I'm receptive if you think this feature is ultimately misguided :) )

I took at stab at implementing the feature in PR #143 . Regarding the attribute name, I went with your *_skip_plan suggestion. However, perhaps something like *_dir_skip_diff_check or disable_*_dir_diff_check could be preferable, so as not to conflate terraform plan and tfmigrate plan?

@minamijoyo
Copy link
Owner

Thank you for working on this and your suggestion. Naming is the most difficult part of design and is always debatable due to personal preferences. In my opinion, *_skip_plan is balanced and simple enough because:

  • The from_ or to_ prefix is more readable when indentation is aligned.
  • Skipping the plan phase of the tfmigrate plan makes no sense, and skipping the plan phase of the tfmigrate apply is actually intended to skip the terraform plan, we still need to modify state on memory, so there is no misunderstanding.
  • The from_skip_diff_check is not bad on its own, but unfortunately, there is a very vaguely named existing force attribute, which, as you know, executes the plan but ignores the diff. In other words, we can say this behavior is skipping the diff check. If we add the from_skip_diff_check, the distinction between force and from_skip_diff_check may be ambiguous. It leaves it open to interpretation whether the terraform plan is executed or not.

You seem to have already fixed the code with *_skip_plan, so let's go forward with this.

@minamijoyo
Copy link
Owner

We shipped #143 in v0.3.14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants