class RubyTerraform::Commands::Destroy
Wraps the +terraform destroy+ command which destroys terraform managed infrastructure.
For options accepted on construction, see {#initialize}.
When executing an instance of {Destroy} via {#execute}, the following options are supported:
-
:directory
: the path to a directory containing terraform configuration (deprecated in terraform 0.14, removed in terraform 0.15, use:chdir
instead). -
:chdir
: the path of a working directory to switch to before executing the given subcommand. -
:auto_approve
: iftrue
, skips interactive approval before destroying; defaults tofalse
. -
:backup
: (legacy) the path to backup the existing state file before modifying; defaults to the:state_out
path with +“.backup”+ extension; set:no_backup
totrue
to skip backups entirely. -
:compact_warnings
: whentrue
, if terraform produces any warnings that are not accompanied by errors, they are shown in a more compact form that includes only the summary messages; defaults tofalse
. -
:input
: whenfalse
, will not ask for input for variables not directly set; defaults totrue
. -
:lock
: whentrue
, locks the state file when locking is supported; whenfalse
, does not lock the state file; defaults totrue
. -
:lock_timeout
: the duration to retry a state lock; defaults to +“0s”+. -
:no_backup
: whentrue
, no backup file will be written; defaults tofalse
. -
:no_color
: whether or not the output from the command should be in color; defaults tofalse
. -
:parallelism
: the number of parallel resource operations; defaults to10
. -
:refresh
: whentrue
, updates state prior to checking for differences; whenfalse
uses locally available state; defaults totrue
. -
:state
: (legacy) the path to the state file from which to read state and in which to store state (unless:state_out
is specified); defaults to +“terraform.tfstate”+. -
:state_out
: (legacy) the path to write state to that is different than:state
; this can be used to preserve the old state. -
:target
: the address of a resource to target; if both:target
and:targets
are provided, all targets will be passed to terraform. -
:targets
: an array of resource addresses to target; if both:target
and:targets
are provided, all targets will be passed to terraform. -
:vars
: a map of variables to be passed to the terraform configuration. -
:var_file
: the path to a terraform var file; if both:var_file
and:var_files
are provided, all var files will be passed to terraform. -
:var_files
: an array of paths to terraform var files; if both:var_file
and:var_files
are provided, all var files will be passed to terraform.
@example Basic Invocation
RubyTerraform::Commands::Destroy.new.execute( directory: 'infra/networking', vars: { region: 'eu-central' })
Public Instance Methods
@!visibility private
# File lib/ruby_terraform/commands/destroy.rb, line 99 def arguments(parameters) [parameters[:directory]] end
@!visibility private
RubyTerraform::Options::Global#options
# File lib/ruby_terraform/commands/destroy.rb, line 77 def options %w[ -auto-approve -backup -compact-warnings -lock -lock-timeout -input -no-color -parallelism -refresh -state -state-out -target -var -var-file ] + super end
@!visibility private
# File lib/ruby_terraform/commands/destroy.rb, line 104 def parameter_defaults(_parameters) { vars: {}, var_files: [], targets: [] } end
@!visibility private
# File lib/ruby_terraform/commands/destroy.rb, line 109 def parameter_overrides(parameters) { backup: parameters[:no_backup] ? '-' : parameters[:backup] } end
@!visibility private
# File lib/ruby_terraform/commands/destroy.rb, line 70 def subcommands %w[destroy] end