From 55ab04303611a7c9a40683d7279e78d13cd05ab5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 2 Oct 2014 22:11:53 -0700 Subject: [PATCH] website: update docs for count.index --- .../docs/configuration/interpolation.html.md | 24 ++++++++++++++----- .../docs/configuration/resources.html.md | 4 +++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/website/source/docs/configuration/interpolation.html.md b/website/source/docs/configuration/interpolation.html.md index 4db6c3b9f..5e43bbd2b 100644 --- a/website/source/docs/configuration/interpolation.html.md +++ b/website/source/docs/configuration/interpolation.html.md @@ -14,7 +14,9 @@ into strings. These interpolations are wrapped in `${}`, such as The interpolation syntax is powerful and allows you to reference variables, attributes of resources, call functions, etc. -To reference variables, use the `var.` prefix followed by the +## Available Variables + +**To reference user variables**, use the `var.` prefix followed by the variable name. For example, `${var.foo}` will interpolate the `foo` variable value. If the variable is a mapping, then you can reference static keys in the map with the syntax @@ -22,18 +24,28 @@ can reference static keys in the map with the syntax get the value of the `us-east-1` key within the `amis` variable that is a mapping. -To reference attributes of other resources, the syntax is +**To reference attributes of other resources**, the syntax is `TYPE.NAME.ATTRIBUTE`. For example, `${aws_instance.web.id}` will interpolate the ID attribute from the "aws\_instance" resource named "web". -Finally, Terraform ships with built-in functions. Functions -are called with the syntax `name(arg, arg2, ...)`. For example, -to read a file: `${file("path.txt")}`. The built-in functions -are documented below. +**To reference outputs from a module**, the syntax is +`MODULE.NAME.OUTPUT`. For example `${module.foo.bar}` will +interpolate the "bar" output from the "foo" +[module](/docs/modules/index.html). + +**To reference count information**, the syntax is `count.FIELD`. +For example, `${count.index}` will interpolate the current index +in a multi-count resource. For more information on count, see the +resource configuration page. ## Built-in Functions +Terraform ships with built-in functions. Functions are called with +the syntax `name(arg, arg2, ...)`. For example, +to read a file: `${file("path.txt")}`. The built-in functions +are documented below. + The supported built-in functions are: * `concat(args...)` - Concatenates the values of multiple arguments into diff --git a/website/source/docs/configuration/resources.html.md b/website/source/docs/configuration/resources.html.md index 1edad4340..03e3eedef 100644 --- a/website/source/docs/configuration/resources.html.md +++ b/website/source/docs/configuration/resources.html.md @@ -42,7 +42,9 @@ resource type in the There are **meta-parameters** available to all resources: * `count` (int) - The number of identical resources to create. - This doesn't apply to all resources. + This doesn't apply to all resources. You can use the `${count.index}` + [interpolation](/docs/configuration/interpolation.html) to reference + the current count index in your resource. * `depends_on` (list of strings) - Explicit dependencies that this resource has. These dependencies will be created before this