Add `terraform state list` command
This introduces the terraform state list command to list the resources within a state. This is the first of many state management commands to come into 0.7. This is the first command of many to come that is considered a "plumbing" command within Terraform (see "plumbing vs porcelain": http://git.661346.n2.nabble.com/what-are-plumbing-and-porcelain-td2190639.html). As such, this PR also introduces a bunch of groundwork to support plumbing commands. The main changes: - Main command output is changed to split "common" and "uncommon" commands. - mitchellh/cli is updated to support nested subcommands, since terraform state list is a nested subcommand. - terraform.StateFilter is introduced as a way in core to filter/search the state files. This is very basic currently but I expect to make it more advanced as time goes on. - terraform state list command is introduced to list resources in a state. This can take a series of arguments to filter this down. Known issues, or things that aren't done in this PR on purpose: - Unit tests for terraform state list are on the way. Unit tests for the core changes are all there.
This commit is contained in:
parent
e81fb10e61
commit
473a58a672
|
@ -54,19 +54,19 @@ func (c *StateListCommand) Run(args []string) int {
|
|||
|
||||
func (c *StateListCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: terraform state list [options] [address...]
|
||||
Usage: terraform state list [options] [pattern...]
|
||||
|
||||
List resources in the Terraform state.
|
||||
|
||||
This command lists resources in the Terraform state. The address argument
|
||||
can be used to filter the resources by resource or module. If no address
|
||||
This command lists resources in the Terraform state. The pattern argument
|
||||
can be used to filter the resources by resource or module. If no pattern
|
||||
is given, all resources are listed.
|
||||
|
||||
The address argument is meant to provide very simple filtering. For
|
||||
The pattern argument is meant to provide very simple filtering. For
|
||||
advanced filtering, please use tools such as "grep". The output of this
|
||||
command is designed to be friendly for this usage.
|
||||
|
||||
The address argument accepts any resource targeting syntax. Please
|
||||
The pattern argument accepts any resource targeting syntax. Please
|
||||
refer to the documentation on resource targeting syntax for more
|
||||
information.
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ configuration are listed first, and resources that are more deeply nested
|
|||
within modules are listed last.
|
||||
|
||||
For complex infrastructures, the state can contain thousands of resources.
|
||||
To filter these, provide one or more addresses to the command. Addresses are
|
||||
To filter these, provide one or more patterns to the command. Patterns are
|
||||
in [resource addressing format](/docs/commands/state/addressing.html).
|
||||
|
||||
The command-line flags are all optional. The list of available flags are:
|
||||
|
|
Loading…
Reference in New Issue