2018-05-06 19:36:32 +02:00
|
|
|
---
|
2020-08-15 03:51:06 +02:00
|
|
|
layout: "language"
|
2020-11-13 03:01:48 +01:00
|
|
|
page_title: "Expressions Landing Page - Configuration Language"
|
2018-05-06 19:36:32 +02:00
|
|
|
sidebar_current: "docs-config-expressions"
|
|
|
|
---
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
# Expressions Landing Page
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
To improve navigation, we've split the old Expressions page into several smaller
|
|
|
|
pages.
|
2019-03-09 03:05:12 +01:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
<a id="types-and-values"></a>
|
|
|
|
<a id="advanced-type-details"></a>
|
|
|
|
<a id="type-conversion"></a>
|
|
|
|
<a id="literal-expressions"></a>
|
|
|
|
<a id="indices-and-attributes"></a>
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
## Types and Values, Literal Expressions, Indices and Attributes
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
Terraform's types are `string`, `number`, `bool`, `list`, `tuple`, `map`,
|
|
|
|
`object`, and `null`.
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
This information has moved to
|
2021-01-15 23:13:53 +01:00
|
|
|
[Types and Values](/docs/language/expressions/types.html).
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2021-08-20 16:31:26 +02:00
|
|
|
<div style="height: 30vh; margin: 0; padding: 0;"></div>
|
website: Add big whitespace separators to recovery landing pages
The resources, expressions, and modules pages were all split into smaller, more
navigable pages, but the old URLs had accumulated a large number of deep links
to their section headers. To help people recover when they click an old link, we
converted those old URLs to landing pages, which preserve all of the old in-page
anchors and point readers to the appropriate new destinations.
However, because the new link-to-new-page sections are so small, it was kind of
hard to tell which section you had clicked into! Especially if you were near the
bottom of the page and the browser wasn't able to position the desired section
at the very top of the window.
This commit aims to improve that by putting one full screen of whitespace in
between every linkable section on these landing pages. Yes, it's a hack, but
you're meant to only view these pages for three seconds or so before moving on
to the place you wanted to be, and this should help dispel any confusion about
which place that is.
2020-12-02 00:27:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
<a id="references-to-named-values"></a>
|
|
|
|
<a id="local-named-values"></a>
|
|
|
|
<a id="named-values-and-dependencies"></a>
|
|
|
|
<a id="references-to-resource-attributes"></a>
|
|
|
|
<a id="local-named-values-1"></a>
|
|
|
|
<a id="values-not-yet-known"></a>
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
## References to Named Values (Resource Attributes, Variables, etc.)
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
You can refer to certain values by name, like `var.some_variable` or
|
|
|
|
`aws_instance.example.ami`.
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
This information has moved to
|
2021-01-15 23:13:53 +01:00
|
|
|
[References to Values](/docs/language/expressions/references.html).
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2021-08-20 16:31:26 +02:00
|
|
|
<div style="height: 30vh; margin: 0; padding: 0;"></div>
|
website: Add big whitespace separators to recovery landing pages
The resources, expressions, and modules pages were all split into smaller, more
navigable pages, but the old URLs had accumulated a large number of deep links
to their section headers. To help people recover when they click an old link, we
converted those old URLs to landing pages, which preserve all of the old in-page
anchors and point readers to the appropriate new destinations.
However, because the new link-to-new-page sections are so small, it was kind of
hard to tell which section you had clicked into! Especially if you were near the
bottom of the page and the browser wasn't able to position the desired section
at the very top of the window.
This commit aims to improve that by putting one full screen of whitespace in
between every linkable section on these landing pages. Yes, it's a hack, but
you're meant to only view these pages for three seconds or so before moving on
to the place you wanted to be, and this should help dispel any confusion about
which place that is.
2020-12-02 00:27:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
<a id="arithmetic-operators"></a>
|
|
|
|
<a id="equality-operators"></a>
|
|
|
|
<a id="comparison-operators"></a>
|
|
|
|
<a id="logical-operators"></a>
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
## Arithmetic and Logical Operators
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
Operators are expressions that transform other expressions, like adding two
|
|
|
|
numbers (`+`) or comparing two values to get a bool (`==`, `>=`, etc.).
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
This information has moved to
|
2021-03-15 14:43:18 +01:00
|
|
|
[Operators](/docs/language/expressions/operators.html).
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2021-08-20 16:31:26 +02:00
|
|
|
<div style="height: 30vh; margin: 0; padding: 0;"></div>
|
website: Add big whitespace separators to recovery landing pages
The resources, expressions, and modules pages were all split into smaller, more
navigable pages, but the old URLs had accumulated a large number of deep links
to their section headers. To help people recover when they click an old link, we
converted those old URLs to landing pages, which preserve all of the old in-page
anchors and point readers to the appropriate new destinations.
However, because the new link-to-new-page sections are so small, it was kind of
hard to tell which section you had clicked into! Especially if you were near the
bottom of the page and the browser wasn't able to position the desired section
at the very top of the window.
This commit aims to improve that by putting one full screen of whitespace in
between every linkable section on these landing pages. Yes, it's a hack, but
you're meant to only view these pages for three seconds or so before moving on
to the place you wanted to be, and this should help dispel any confusion about
which place that is.
2020-12-02 00:27:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-05-06 19:36:32 +02:00
|
|
|
## Conditional Expressions
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
The `condition ? true_val : false_val` expression chooses between two
|
|
|
|
expressions based on a bool condition.
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
This information has moved to
|
2021-01-15 23:13:53 +01:00
|
|
|
[Conditional Expressions](/docs/language/expressions/conditionals.html).
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2021-08-20 16:31:26 +02:00
|
|
|
<div style="height: 30vh; margin: 0; padding: 0;"></div>
|
website: Add big whitespace separators to recovery landing pages
The resources, expressions, and modules pages were all split into smaller, more
navigable pages, but the old URLs had accumulated a large number of deep links
to their section headers. To help people recover when they click an old link, we
converted those old URLs to landing pages, which preserve all of the old in-page
anchors and point readers to the appropriate new destinations.
However, because the new link-to-new-page sections are so small, it was kind of
hard to tell which section you had clicked into! Especially if you were near the
bottom of the page and the browser wasn't able to position the desired section
at the very top of the window.
This commit aims to improve that by putting one full screen of whitespace in
between every linkable section on these landing pages. Yes, it's a hack, but
you're meant to only view these pages for three seconds or so before moving on
to the place you wanted to be, and this should help dispel any confusion about
which place that is.
2020-12-02 00:27:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
<a id="expanding-function-arguments"></a>
|
|
|
|
<a id="available-functions"></a>
|
2018-05-06 19:36:32 +02:00
|
|
|
|
|
|
|
## Function Calls
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
Terraform's functions can be called like `function_name(arg1, arg2)`.
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
This information has moved to
|
2021-01-15 23:13:53 +01:00
|
|
|
[Function Calls](/docs/language/expressions/function-calls.html).
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2021-08-20 16:31:26 +02:00
|
|
|
<div style="height: 30vh; margin: 0; padding: 0;"></div>
|
website: Add big whitespace separators to recovery landing pages
The resources, expressions, and modules pages were all split into smaller, more
navigable pages, but the old URLs had accumulated a large number of deep links
to their section headers. To help people recover when they click an old link, we
converted those old URLs to landing pages, which preserve all of the old in-page
anchors and point readers to the appropriate new destinations.
However, because the new link-to-new-page sections are so small, it was kind of
hard to tell which section you had clicked into! Especially if you were near the
bottom of the page and the browser wasn't able to position the desired section
at the very top of the window.
This commit aims to improve that by putting one full screen of whitespace in
between every linkable section on these landing pages. Yes, it's a hack, but
you're meant to only view these pages for three seconds or so before moving on
to the place you wanted to be, and this should help dispel any confusion about
which place that is.
2020-12-02 00:27:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
<a id="for-expressions"></a>
|
2018-05-06 19:36:32 +02:00
|
|
|
|
|
|
|
## `for` Expressions
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
Expressions like `[for s in var.list : upper(s)]` can transform a complex type
|
|
|
|
value into another complex type value.
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
This information has moved to
|
2021-01-15 23:13:53 +01:00
|
|
|
[For Expressions](/docs/language/expressions/for.html).
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2021-08-20 16:31:26 +02:00
|
|
|
<div style="height: 30vh; margin: 0; padding: 0;"></div>
|
website: Add big whitespace separators to recovery landing pages
The resources, expressions, and modules pages were all split into smaller, more
navigable pages, but the old URLs had accumulated a large number of deep links
to their section headers. To help people recover when they click an old link, we
converted those old URLs to landing pages, which preserve all of the old in-page
anchors and point readers to the appropriate new destinations.
However, because the new link-to-new-page sections are so small, it was kind of
hard to tell which section you had clicked into! Especially if you were near the
bottom of the page and the browser wasn't able to position the desired section
at the very top of the window.
This commit aims to improve that by putting one full screen of whitespace in
between every linkable section on these landing pages. Yes, it's a hack, but
you're meant to only view these pages for three seconds or so before moving on
to the place you wanted to be, and this should help dispel any confusion about
which place that is.
2020-12-02 00:27:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
<a id="splat-expressions"></a>
|
|
|
|
<a id="legacy-attribute-only-splat-expressions"></a>
|
2020-06-01 20:23:56 +02:00
|
|
|
|
2018-05-06 19:36:32 +02:00
|
|
|
## Splat Expressions
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
Expressions like `var.list[*].id` can extract simpler collections from complex
|
|
|
|
collections.
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
This information has moved to
|
2021-01-15 23:13:53 +01:00
|
|
|
[Splat Expressions](/docs/language/expressions/splat.html).
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2021-08-20 16:31:26 +02:00
|
|
|
<div style="height: 30vh; margin: 0; padding: 0;"></div>
|
website: Add big whitespace separators to recovery landing pages
The resources, expressions, and modules pages were all split into smaller, more
navigable pages, but the old URLs had accumulated a large number of deep links
to their section headers. To help people recover when they click an old link, we
converted those old URLs to landing pages, which preserve all of the old in-page
anchors and point readers to the appropriate new destinations.
However, because the new link-to-new-page sections are so small, it was kind of
hard to tell which section you had clicked into! Especially if you were near the
bottom of the page and the browser wasn't able to position the desired section
at the very top of the window.
This commit aims to improve that by putting one full screen of whitespace in
between every linkable section on these landing pages. Yes, it's a hack, but
you're meant to only view these pages for three seconds or so before moving on
to the place you wanted to be, and this should help dispel any confusion about
which place that is.
2020-12-02 00:27:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
<a id="dynamic-blocks"></a>
|
|
|
|
<a id="best-practices-for-dynamic-blocks"></a>
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
## `dynamic` Blocks
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
The special `dynamic` block type serves the same purpose as a `for` expression,
|
|
|
|
except it creates multiple repeatable nested blocks instead of a complex value.
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
This information has moved to
|
2021-01-15 23:13:53 +01:00
|
|
|
[Dynamic Blocks](/docs/language/expressions/dynamic-blocks.html).
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2021-08-20 16:31:26 +02:00
|
|
|
<div style="height: 30vh; margin: 0; padding: 0;"></div>
|
website: Add big whitespace separators to recovery landing pages
The resources, expressions, and modules pages were all split into smaller, more
navigable pages, but the old URLs had accumulated a large number of deep links
to their section headers. To help people recover when they click an old link, we
converted those old URLs to landing pages, which preserve all of the old in-page
anchors and point readers to the appropriate new destinations.
However, because the new link-to-new-page sections are so small, it was kind of
hard to tell which section you had clicked into! Especially if you were near the
bottom of the page and the browser wasn't able to position the desired section
at the very top of the window.
This commit aims to improve that by putting one full screen of whitespace in
between every linkable section on these landing pages. Yes, it's a hack, but
you're meant to only view these pages for three seconds or so before moving on
to the place you wanted to be, and this should help dispel any confusion about
which place that is.
2020-12-02 00:27:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
<a id="string-literals"></a>
|
|
|
|
<a id="string-templates"></a>
|
|
|
|
<a id="interpolation"></a>
|
|
|
|
<a id="directives"></a>
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
## String Literals and String Templates
|
2019-10-01 17:25:57 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
Strings can be `"double-quoted"` or
|
2018-05-06 19:36:32 +02:00
|
|
|
|
|
|
|
```hcl
|
|
|
|
<<EOT
|
2020-11-13 03:01:48 +01:00
|
|
|
heredocs
|
2018-05-06 19:36:32 +02:00
|
|
|
EOT
|
|
|
|
```
|
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
Strings can also include escape sequences like `\n`, interpolation sequences
|
|
|
|
(`${ ... }`), and template sequences (`%{ ... }`).
|
2018-05-06 19:36:32 +02:00
|
|
|
|
2020-11-13 03:01:48 +01:00
|
|
|
This information has moved to
|
2021-01-15 23:13:53 +01:00
|
|
|
[Strings and Templates](/docs/language/expressions/strings.html).
|
website: Add big whitespace separators to recovery landing pages
The resources, expressions, and modules pages were all split into smaller, more
navigable pages, but the old URLs had accumulated a large number of deep links
to their section headers. To help people recover when they click an old link, we
converted those old URLs to landing pages, which preserve all of the old in-page
anchors and point readers to the appropriate new destinations.
However, because the new link-to-new-page sections are so small, it was kind of
hard to tell which section you had clicked into! Especially if you were near the
bottom of the page and the browser wasn't able to position the desired section
at the very top of the window.
This commit aims to improve that by putting one full screen of whitespace in
between every linkable section on these landing pages. Yes, it's a hack, but
you're meant to only view these pages for three seconds or so before moving on
to the place you wanted to be, and this should help dispel any confusion about
which place that is.
2020-12-02 00:27:41 +01:00
|
|
|
|
2021-08-20 16:31:26 +02:00
|
|
|
<div style="height: 30vh; margin: 0; padding: 0;"></div>
|