github.com/wikibal01/hashicorp-terraform@v0.11.12-beta1/website/docs/commands/state/list.html.md (about) 1 --- 2 layout: "commands-state" 3 page_title: "Command: state list" 4 sidebar_current: "docs-state-sub-list" 5 description: |- 6 The terraform state list command is used to list resources within a Terraform state. 7 --- 8 9 # Command: state list 10 11 The `terraform state list` command is used to list resources within a 12 [Terraform state](/docs/state/index.html). 13 14 ## Usage 15 16 Usage: `terraform state list [options] [address...]` 17 18 The command will list all resources in the state file matching the given 19 addresses (if any). If no addresses are given, all resources are listed. 20 21 The resources listed are sorted according to module depth order followed 22 by alphabetical. This means that resources that are in your immediate 23 configuration are listed first, and resources that are more deeply nested 24 within modules are listed last. 25 26 For complex infrastructures, the state can contain thousands of resources. 27 To filter these, provide one or more patterns to the command. Patterns are 28 in [resource addressing format](/docs/commands/state/addressing.html). 29 30 The command-line flags are all optional. The list of available flags are: 31 32 * `-state=path` - Path to the state file. Defaults to "terraform.tfstate". 33 Ignored when [remote state](/docs/state/remote.html) is used. 34 * `-id=id` - ID of resources to show. Ignored when unset. 35 36 ## Example: All Resources 37 38 This example will list all resources, including modules: 39 40 ``` 41 $ terraform state list 42 aws_instance.foo 43 aws_instance.bar[0] 44 aws_instance.bar[1] 45 module.elb.aws_elb.main 46 ``` 47 48 ## Example: Filtering by Resource 49 50 This example will only list resources for the given name: 51 52 ``` 53 $ terraform state list aws_instance.bar 54 aws_instance.bar[0] 55 aws_instance.bar[1] 56 ``` 57 58 ## Example: Filtering by Module 59 60 This example will only list resources in the given module: 61 62 ``` 63 $ terraform state list module.elb 64 module.elb.aws_elb.main 65 ``` 66 67 ## Example: Filtering by ID 68 69 This example will only list the resource whose ID is specified on the 70 command line. This is useful to find where in your configuration a 71 specific resource is located. 72 73 ``` 74 $ terraform state list -id=sg-1234abcd 75 module.elb.aws_security_group.sg 76 ```