From 473a58a672bf0bd90775e8e2eb1c21521bff2ab8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 22 Mar 2016 10:41:02 -0700 Subject: [PATCH] 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. --- command/state_list.go | 10 +++++----- website/source/docs/commands/state/list.html.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/command/state_list.go b/command/state_list.go index 4aa4a688b..daa96b684 100644 --- a/command/state_list.go +++ b/command/state_list.go @@ -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. diff --git a/website/source/docs/commands/state/list.html.md b/website/source/docs/commands/state/list.html.md index a785e90b4..e4350d483 100644 --- a/website/source/docs/commands/state/list.html.md +++ b/website/source/docs/commands/state/list.html.md @@ -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: