busser/tfautomv

Run `tfautomv` against a plan file

gzur opened this issue · 4 comments

gzur commented

Hi,

Is it possible to run tfautomv against an existing plan file?

I.e. something like:

$ terraform plan -out tfplan
[...]
$ tfautomv -plan tfplan

And if not, is it feasible to implement?

Hey @gzur 👋

This currently isn't possible but can definitely be implemented. Currently, tfautomv runs a plan -out tfplan command and then parses the plan file. I don't see why the user couldn't provide a plan file directly.

I'm curious: what is your usecase for running the plan command separately?

gzur commented

I was running tfautomv against an environment (containing about 260 resources), and it had hung for about 20 minutes when I started thinking about this and created this issue.

I was able plan normally against the environment, so I wondered whether I could supply the plan file myself.

What ended up happening though, was that I Ctrl-C'd tfautomv, upgraded to v0.6.0 and ran it against with the new-fangled -sS options and it flew through, returning 115 valid move commands (I was refactoring 🤠).

I have no idea whether the issue had anything to do with tfautomv or the underlying provider, (or whether -sS saved the day ¯_(ツ)_/¯ )

But having said this, I can imagine a local plan file might be nice if you are trying to fine-tune --ignore clauses.

Interesting! Thanks for providing your use case 😊

Indeed the -sS flags are a great time saver. I agree that computing the plan again and again when iterating on rules is a waste of time, although in my experience it's not a big one.

I'm not against allowing users to provide plan files to tfautomv. I wonder what that would look like when running tfautomv on multiple directories at once (another v0.6 feature). To work in "multi-directory" mode, tfautomv needs to know the path to each directory.

Maybe something like this:

tfautomv dir1/tfplan dir2/tfplan dir3/tfplan

tfautomv would then assume that the directories are dir1, dir2, and dir3? I'm not certain that that assumption would always be convenient for users.

I'd be curious to know what other use cases there are where users would want to provide plan files instead of having tfautomv run the plan command. Perhaps then the correct UX would be more obvious.