class RubyTerraform::Commands::StateMove

Wraps the +terraform state mv+ command which moves an item in the state.

This command will move an item matched by the address given to the destination address. This command can also move to a destination address in a completely different state file.

This can be used for simple resource renaming, moving items to and from a module, moving entire modules, and more. And because this command can also move data to a completely new state, it can also be used for refactoring one configuration into multiple separately managed Terraform configurations.

This command will output a backup copy of the state prior to saving any changes. The backup cannot be disabled. Due to the destructive nature of this command, backups are required.

If you're moving an item to a different state file, a backup will be created for each state file.

For options accepted on construction, see {#initialize}.

When executing an instance of {StateMove} via {#execute}, the following options are supported:

@example Basic Invocation

RubyTerraform::Commands::StateMove.new.execute(
  source: 'packet_device.worker',
  destination: 'packet_device.helper')

Public Instance Methods

arguments(parameters) click to toggle source

@!visibility private

# File lib/ruby_terraform/commands/state_move.rb, line 87
def arguments(parameters)
  [parameters[:source], parameters[:destination]]
end
options() click to toggle source

@!visibility private

Calls superclass method RubyTerraform::Options::Global#options
# File lib/ruby_terraform/commands/state_move.rb, line 73
def options
  %w[
    -dry-run
    -backup
    -backup-out
    -lock
    -lock-timeout
    -state
    -state-out
    -ignore-remote-version
  ] + super
end
subcommands() click to toggle source

@!visibility private

# File lib/ruby_terraform/commands/state_move.rb, line 68
def subcommands
  %w[state mv]
end