Class: RubyTerraform::Commands::StateList

Inherits:
Base
  • Object
show all
Includes:
Options::Global
Defined in:
lib/ruby_terraform/commands/state_list.rb

Overview

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 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 Base#initialize.

When executing an instance of StateList via Base#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.

The Base#execute method accepts an optional second parameter which is a map of invocation options. Currently, the only supported option is :environment which is a map of environment variables to expose during invocation of the command.

Examples:

Basic Invocation

RubyTerraform::Commands::StateList.new.execute

Constructor Details

This class inherits a constructor from RubyTerraform::Commands::Base