github.com/hugorut/terraform@v1.1.3/website/docs/cli/commands/state/show.mdx (about) 1 --- 2 page_title: 'Command: state show' 3 description: >- 4 The `terraform state show` command is used to show the attributes of a single 5 resource in the Terraform state. 6 --- 7 8 # Command: state show 9 10 The `terraform state show` command is used to show the attributes of a 11 single resource in the 12 [Terraform state](/language/state). 13 14 ## Usage 15 16 Usage: `terraform state show [options] ADDRESS` 17 18 The command will show the attributes of a single resource in the 19 state file that matches the given address. 20 21 This command requires an address that points to a single resource in the 22 state. Addresses are 23 in [resource addressing format](/cli/state/resource-addressing). 24 25 The command-line flags are all optional. The list of available flags are: 26 27 * `-state=path` - Path to the state file. Defaults to "terraform.tfstate". 28 Ignored when [remote state](/language/state/remote) is used. 29 30 The output of `terraform state show` is intended for human consumption, not 31 programmatic consumption. To extract state data for use in other software, use 32 [`terraform show -json`](/cli/commands/show#json-output) and decode the result 33 using the documented structure. 34 35 ## Example: Show a Resource 36 37 The example below shows a `packet_device` resource named `worker`: 38 39 ``` 40 $ terraform state show 'packet_device.worker' 41 # packet_device.worker: 42 resource "packet_device" "worker" { 43 billing_cycle = "hourly" 44 created = "2015-12-17T00:06:56Z" 45 facility = "ewr1" 46 hostname = "prod-xyz01" 47 id = "6015bg2b-b8c4-4925-aad2-f0671d5d3b13" 48 locked = false 49 } 50 ``` 51 52 ## Example: Show a Module Resource 53 54 The example below shows a `packet_device` resource named `worker` inside a module named `foo`: 55 56 ```shell 57 $ terraform state show 'module.foo.packet_device.worker' 58 ``` 59 60 ## Example: Show a Resource configured with count 61 62 The example below shows the first instance of a `packet_device` resource named `worker` configured with 63 [`count`](/language/meta-arguments/count): 64 65 ```shell 66 $ terraform state show 'packet_device.worker[0]' 67 ``` 68 69 ## Example: Show a Resource configured with for_each 70 71 The example below shows the `"example"` instance of a `packet_device` resource named `worker` configured with 72 [`for_each`](/language/meta-arguments/for_each): 73 74 Linux, Mac OS, and UNIX: 75 76 ```shell 77 $ terraform state show 'packet_device.worker["example"]' 78 ``` 79 80 PowerShell: 81 82 ```shell 83 $ terraform state show 'packet_device.worker[\"example\"]' 84 ``` 85 86 Windows `cmd.exe`: 87 88 ```shell 89 $ terraform state show packet_device.worker[\"example\"] 90 ```