From 5737c0a13b6a9e8cefbb6ea237d3d6df6274f88e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 25 Mar 2016 10:26:30 -0700 Subject: [PATCH] website: update docs for state show --- command/state_show.go | 4 +- .../source/docs/commands/state/list.html.md | 2 +- .../source/docs/commands/state/show.html.md | 47 +++++++++++++++++++ website/source/layouts/commands-state.erb | 4 ++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 website/source/docs/commands/state/show.html.md diff --git a/command/state_show.go b/command/state_show.go index 00c97816e..0f1b7285c 100644 --- a/command/state_show.go +++ b/command/state_show.go @@ -63,7 +63,9 @@ func (c *StateShowCommand) Run(args []string) int { output := make([]string, 0, len(is.Attributes)+1) output = append(output, fmt.Sprintf("id | %s", is.ID)) for _, k := range keys { - output = append(output, fmt.Sprintf("%s | %s", k, is.Attributes[k])) + if k != "id" { + output = append(output, fmt.Sprintf("%s | %s", k, is.Attributes[k])) + } } // Output diff --git a/website/source/docs/commands/state/list.html.md b/website/source/docs/commands/state/list.html.md index da63da34b..a571d6ff5 100644 --- a/website/source/docs/commands/state/list.html.md +++ b/website/source/docs/commands/state/list.html.md @@ -3,7 +3,7 @@ layout: "commands-state" page_title: "Command: state list" sidebar_current: "docs-state-sub-list" description: |- - The `terraform init` command is used to initialize a Terraform configuration using another module as a skeleton. + The terraform state list command is used to list resources within a Terraform state. --- # Command: state list diff --git a/website/source/docs/commands/state/show.html.md b/website/source/docs/commands/state/show.html.md new file mode 100644 index 000000000..3ca6e9619 --- /dev/null +++ b/website/source/docs/commands/state/show.html.md @@ -0,0 +1,47 @@ +--- +layout: "commands-state" +page_title: "Command: state show" +sidebar_current: "docs-state-sub-show" +description: |- + The `terraform state show` command is used to show the attributes of a single resource in the Terraform state. +--- + +# Command: state show + +The `terraform state show` command is used to show the attributes of a +single resource in the +[Terraform state](/docs/state/index.html). + +## Usage + +Usage: `terraform state show [options] PATTERN` + +The command will show the attributes of a single resource in the +state file that matches the given pattern. + +The attributes are listed in alphabetical order (with the except of "id" +which is always at the top). They are outputted in a way that is easy +to parse on the command-line. + +This command requires a pattern that points to a single resource in the +state. Patterns are +in [resource addressing format](/docs/commands/state/addressing.html). + +The command-line flags are all optional. The list of available flags are: + +* `-state=path` - Path to the state file. Defaults to "terraform.tfstate". + +## Example: Show a Resource + +The example below shows a resource: + +``` +$ terraform state show module.foo.packet_device.worker[0] +id = 6015bg2b-b8c4-4925-aad2-f0671d5d3b13 +billing_cycle = hourly +created = 2015-12-17T00:06:56Z +facility = ewr1 +hostname = prod-xyz01 +locked = false +... +``` diff --git a/website/source/layouts/commands-state.erb b/website/source/layouts/commands-state.erb index 674cb4834..e182f0d2e 100644 --- a/website/source/layouts/commands-state.erb +++ b/website/source/layouts/commands-state.erb @@ -20,6 +20,10 @@ > list + + > + show +