mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-16 01:00:22 -04:00
1.1 KiB
1.1 KiB
layout, page_title, sidebar_current, description
| layout | page_title | sidebar_current | description |
|---|---|---|---|
| docs | Internals: Resource Address | docs-internals-resource-addressing | Resource addressing is used to target specific resources in a larger infrastructure. |
Resource Addressing
A Resource Address is a string that references a specific resource in a larger infrastructure. The syntax of a resource address is:
<resource_type>.<resource_name>[optional fields]
Required fields:
resource_type- Type of the resource being addressed.resource_name- User-defined name of the resource.
Optional fields may include:
[N]- whereNis a0-based index into a resource with multiple instances specified by thecountmeta-parameter. Omitting an index when addressing a resource wherecount > 1means that the address references all instances.
Examples
Given a Terraform config that includes:
resource "aws_instance" "web" {
# ...
count = 4
}
An address like this:
aws_instance.web[3]
Refers to only the last instance in the config, and an address like this:
aws_instance.web
Refers to all four "web" instances.