infrablocks / ruby_terraform

A simple Ruby wrapper for invoking terraform commands.
MIT License
109 stars 33 forks source link

Support for terraform state push command #21

Closed kief closed 3 years ago

kief commented 5 years ago

I want to be able to bootstrap infrastructure needed for remote state by first creating the infrastructure using local state, then change to a remote backend and migrate the state. This would work fine with the default statefile location and name, but doesn't work with the state in a non-default location.

I've hacked a way to do this by copying the state into the working copy of the terraform copy after running the init command, before running plan or apply. But using the "terraform state push" command may be a cleaner way to do this.

So, it would be useful to add support for "terraform state push" to ruby_terraform. I'm not sure, at a glance, how to support a two-level subcommand like this. I'm also not sure whether I want to shave the yaks of supporting (and testing) the other "terraform state" subcommands.

tobyclemson commented 5 years ago

Hi Kief,

So you’re looking specifically for the terraform state push command? I think it’s fine to add that and not the others for now and would happily accept a PR.

In terms of nested subcommands, lino supports that already and it is in use inside of ruby_terraform. Take a look at lib/ruby_terraform/commands/remote_config.rb for an example.

Thanks, Toby