github.com/jrasell/terraform@v0.6.17-0.20160523115548-2652f5232949/website/source/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 34 ## Example: All Resources 35 36 This example will list all resources, including modules: 37 38 ``` 39 $ terraform state list 40 aws_instance.foo 41 aws_instance.bar[0] 42 aws_instance.bar[1] 43 module.elb.aws_elb.main 44 ``` 45 46 ## Example: Filtering by Resource 47 48 This example will only list resources for the given name: 49 50 ``` 51 $ terraform state list aws_instance.bar 52 aws_instance.bar[0] 53 aws_instance.bar[1] 54 ``` 55 56 ## Example: Filtering by Module 57 58 This example will only list resources in the given module: 59 60 ``` 61 $ terraform state list module.elb 62 module.elb.aws_elb.main 63 ```