» Resource Addressing

A Resource Address is a string that references a specific resource in a larger infrastructure. An address is made up of two parts:

[module path][resource spec]

Module path:

A module path addresses a module within the tree of modules. It takes the form:


Multiple modules in a path indicate nesting. If a module path is specified without a resource spec, the address applies to every resource within the module. If the module path is omitted, this addresses the root module.

Resource spec:

A resource spec addresses a specific resource in the config. It takes the form:

  • resource_type - Type of the resource being addressed.
  • resource_name - User-defined name of the resource.
  • [N] - where N is a 0-based index into a resource with multiple instances specified by the count meta-parameter. Omitting an index when addressing a resource where count > 1 means that the address references all instances.

» Examples

Given a Terraform config that includes:

resource "aws_instance" "web" {
  # ...
  count = 4

An address like this:


Refers to only the last instance in the config, and an address like this:


Refers to all four "web" instances.