class RubyTerraform::Commands::StateList
Wraps the +terraform state list+ command which lists resources in the Terraform state.
This command lists resource instances in the Terraform state. The address option can be used to filter the instances by resource or module. If no pattern is given, all resource instances are listed.
The addresses must either be module addresses or absolute resource addresses, such as:
-
aws_instance.example
-
module.example
-
module.example.module.child
-
module.example.aws_instance.example
An {RubyTerraform::Errors::ExecutionError} will be raised if any of the resources or modules given as filter addresses do not exist in the state.
For options accepted on construction, see {#initialize}.
When executing an instance of {StateList} via {#execute}, the following options are supported:
-
:address
: the module address or absolute resource address to filter by; if both:address
and:addresses
are provided, all addresses will be passed to Terraform. -
:addresses
: an array of module addresses or absolute resource addresses to filter by; if both:address
and:addresses
are provided, all addresses will be passed to Terraform. -
:chdir
: the path of a working directory to switch to before executing the given subcommand. -
:state
: the path to a Terraform state file to use to look up Terraform-managed resources; by default, Terraform will consult the state of the currently-selected workspace. -
:id
: when provided, filters the results to include only instances whose resource types have an attribute named “id” whose value equals the given id string.
@example Basic Invocation
RubyTerraform::Commands::StateList.new.execute
Public Instance Methods
@!visibility private
# File lib/ruby_terraform/commands/state_list.rb, line 66 def arguments(parameters) [parameters[:address], parameters[:addresses]] end
@!visibility private
RubyTerraform::Options::Global#options
# File lib/ruby_terraform/commands/state_list.rb, line 58 def options %w[ -state -id ] + super end
@!visibility private
# File lib/ruby_terraform/commands/state_list.rb, line 53 def subcommands %w[state list] end