github.com/nicgrayson/terraform@v0.4.3-0.20150415203910-c4de50829380/website/source/docs/internals/resource-addressing.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "Internals: Resource Address" 4 sidebar_current: "docs-internals-resource-addressing" 5 description: |- 6 Resource addressing is used to target specific resources in a larger 7 infrastructure. 8 --- 9 10 # Resource Addressing 11 12 A __Resource Address__ is a string that references a specific resource in a 13 larger infrastructure. The syntax of a resource address is: 14 15 ``` 16 <resource_type>.<resource_name>[optional fields] 17 ``` 18 19 Required fields: 20 21 * `resource_type` - Type of the resource being addressed. 22 * `resource_name` - User-defined name of the resource. 23 24 Optional fields may include: 25 26 * `[N]` - where `N` is a `0`-based index into a resource with multiple 27 instances specified by the `count` meta-parameter. Omitting an index when 28 addressing a resource where `count > 1` means that the address references 29 all instances. 30 31 32 ## Examples 33 34 Given a Terraform config that includes: 35 36 ``` 37 resource "aws_instance" "web" { 38 # ... 39 count = 4 40 } 41 ``` 42 43 An address like this: 44 45 46 ``` 47 aws_instance.web[3] 48 ``` 49 50 Refers to only the last instance in the config, and an address like this: 51 52 ``` 53 aws_instance.web 54 ``` 55 56 57 Refers to all four "web" instances.