github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/commands/state/show.html.md (about)

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