mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-21 02:37:43 -05:00
69 lines
2.8 KiB
Plaintext
69 lines
2.8 KiB
Plaintext
---
|
|
description: >-
|
|
An overview of expressions to reference or compute values in OpenTofu
|
|
configurations, including types, operators, and functions.
|
|
---
|
|
|
|
# Expressions
|
|
|
|
_Expressions_ refer to or compute values within a configuration.
|
|
The simplest expressions are just literal values, like `"hello"` or `5`,
|
|
but the OpenTofu language also allows more complex expressions such as
|
|
references to data exported by resources, arithmetic, conditional evaluation,
|
|
and a number of built-in and provider-defined functions.
|
|
|
|
Expressions can be used in a number of places in the OpenTofu language,
|
|
but some contexts limit which expression constructs are allowed,
|
|
such as requiring a literal value of a particular type or forbidding
|
|
[references to resource attributes](references.mdx#references-to-resource-attributes).
|
|
Each language feature's documentation describes any restrictions it places on
|
|
expressions.
|
|
|
|
You can experiment with the behavior of OpenTofu's expressions from
|
|
the OpenTofu expression console, by running
|
|
[the `tofu console` command](../../cli/commands/console.mdx).
|
|
|
|
The other pages in this section describe the features of OpenTofu's
|
|
expression syntax.
|
|
|
|
- [Types and Values](types.mdx)
|
|
documents the data types that OpenTofu expressions can resolve to, and the
|
|
literal syntaxes for values of those types.
|
|
|
|
- [Strings and Templates](strings.mdx)
|
|
documents the syntaxes for string literals, including interpolation sequences
|
|
and template directives.
|
|
|
|
- [References to Values](references.mdx)
|
|
documents how to refer to named values like variables and resource attributes.
|
|
|
|
- [Operators](operators.mdx)
|
|
documents the arithmetic, comparison, and logical operators.
|
|
|
|
- [Function Calls](function-calls.mdx)
|
|
documents the syntax for calling OpenTofu's built-in functions.
|
|
|
|
- [Conditional Expressions](conditionals.mdx)
|
|
documents the `<CONDITION> ? <TRUE VAL> : <FALSE VAL>` expression, which
|
|
chooses between two values based on a bool condition.
|
|
|
|
- [For Expressions](for.mdx)
|
|
documents expressions like `[for s in var.list : upper(s)]`, which can
|
|
transform a complex type value into another complex type value.
|
|
|
|
- [Splat Expressions](splat.mdx)
|
|
documents expressions like `var.list[*].id`, which can extract simpler
|
|
collections from more complicated expressions.
|
|
|
|
- [Dynamic Blocks](dynamic-blocks.mdx)
|
|
documents a way to create multiple repeatable nested blocks within a resource
|
|
or other construct.
|
|
|
|
- [Type Constraints](type-constraints.mdx)
|
|
documents the syntax for referring to a type, rather than a value of that
|
|
type. Input variables expect this syntax in their `type` argument.
|
|
|
|
- [Version Constraints](version-constraints.mdx)
|
|
documents the syntax of special strings that define a set of allowed software
|
|
versions. OpenTofu uses version constraints in several places.
|