From 146644a84801810ec9518c5d224df8d8e852171c Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:13:18 -0400 Subject: [PATCH] update addressing section --- .../resource-addressing.html.markdown | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/website/docs/internals/resource-addressing.html.markdown b/website/docs/internals/resource-addressing.html.markdown index ec157e271..51ff80c97 100644 --- a/website/docs/internals/resource-addressing.html.markdown +++ b/website/docs/internals/resource-addressing.html.markdown @@ -16,7 +16,7 @@ larger infrastructure. An address is made up of two parts: [module path][resource spec] ``` -__Module path__: +## Module path A module path addresses a module within the tree of modules. It takes the form: @@ -27,8 +27,8 @@ module.module_name[module index] * `module` - Module keyword indicating a child module (non-root). Multiple `module` keywords in a path indicate nesting. * `module_name` - User-defined name of the module. - * `[module index]` - (Optional) Index into a module with multiple - instances, surrounded by square brace characters (`[` and `]`). + * `[module index]` - (Optional) [Index](#index-values-for-modules-and-resources) into a + module with multiple instances, surrounded by square brace characters (`[` and `]`). An address without a resource spec, i.e. `module.foo` applies to every resource within the module if a single module, or all instances of a module if a module has multiple instances. @@ -37,10 +37,16 @@ such as `module.foo[0]`. If the module path is omitted, the address applies to the root module. +An example of the `module` keyword delineating between two modules that have multiple instances: + +``` +module.foo[0].module.bar["a"] +``` + -> Module index only applies to modules in Terraform v0.13 or later, as in earlier versions of Terraform, a module could not have multiple instances. -__Resource spec__: +## Resource spec A resource spec addresses a specific resource in the config. It takes the form: @@ -50,15 +56,15 @@ resource_type.resource_name[resource index] * `resource_type` - Type of the resource being addressed. * `resource_name` - User-defined name of the resource. - * `[resource index]` - (Optional) Index into a resource with multiple - instances, surrounded by square brace characters (`[` and `]`). + * `[resource index]` - (Optional) [Index](#index-values-for-modules-and-resources) + into a resource with multiple instances, surrounded by square brace characters (`[` and `]`). -> In Terraform v0.12 and later, a resource spec without a module path prefix matches only resources in the root module. In earlier versions, a resource spec without a module path prefix will match resources with the same type and name in any descendent module. -__Index values for Modules and Resources__: +## Index values for Modules and Resources The following specifications apply to index values on modules and resources with multiple instances: