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