mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Update website/docs/language/functions
(#227)
Signed-off-by: Marcin Białoń <mbialon@spacelift.io>
This commit is contained in:
parent
19c658c516
commit
554f303899
@ -12,12 +12,12 @@ with the current working directory.
|
||||
Referring directly to filesystem paths in resource arguments may cause
|
||||
spurious diffs if the same configuration is applied from multiple systems or on
|
||||
different host operating systems. We recommend using filesystem paths only
|
||||
for transient values, such as the argument to [`file`](/terraform/language/functions/file) (where
|
||||
for transient values, such as the argument to [`file`](/opentf/language/functions/file) (where
|
||||
only the contents are then stored) or in `connection` and `provisioner` blocks.
|
||||
|
||||
## Examples
|
||||
|
||||
```
|
||||
> abspath(path.root)
|
||||
/home/user/some/terraform/root
|
||||
/home/user/some/opentf/root
|
||||
```
|
||||
|
@ -7,8 +7,6 @@ description: |-
|
||||
|
||||
# `alltrue` Function
|
||||
|
||||
-> **Note:** This function is available in Terraform 0.14 and later.
|
||||
|
||||
`alltrue` returns `true` if all elements in a given collection are `true`
|
||||
or `"true"`. It also returns `true` if the collection is empty.
|
||||
|
||||
|
@ -7,8 +7,6 @@ description: |-
|
||||
|
||||
# `anytrue` Function
|
||||
|
||||
-> **Note:** This function is available in Terraform 0.14 and later.
|
||||
|
||||
`anytrue` returns `true` if any element in a given collection is `true`
|
||||
or `"true"`. It also returns `false` if the collection is empty.
|
||||
|
||||
|
@ -8,15 +8,15 @@ description: The base64decode function decodes a string containing a base64 sequ
|
||||
`base64decode` takes a string containing a Base64 character sequence and
|
||||
returns the original string.
|
||||
|
||||
Terraform uses the "standard" Base64 alphabet as defined in
|
||||
OpenTF uses the "standard" Base64 alphabet as defined in
|
||||
[RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
|
||||
|
||||
Strings in the Terraform language are sequences of unicode characters rather
|
||||
Strings in the OpenTF language are sequences of unicode characters rather
|
||||
than bytes, so this function will also interpret the resulting bytes as
|
||||
UTF-8. If the bytes after Base64 decoding are _not_ valid UTF-8, this function
|
||||
produces an error.
|
||||
|
||||
While we do not recommend manipulating large, raw binary data in the Terraform
|
||||
While we do not recommend manipulating large, raw binary data in the OpenTF
|
||||
language, Base64 encoding is the standard way to represent arbitrary byte
|
||||
sequences, and so resource types that accept or return binary data will use
|
||||
Base64 themselves, which avoids the need to encode or decode it directly in
|
||||
@ -24,7 +24,7 @@ most cases. Various other functions with names containing "base64" can generate
|
||||
or manipulate Base64 data directly.
|
||||
|
||||
`base64decode` is, in effect, a shorthand for calling
|
||||
[`textdecodebase64`](/terraform/language/functions/textdecodebase64) with the encoding name set to
|
||||
[`textdecodebase64`](/opentf/language/functions/textdecodebase64) with the encoding name set to
|
||||
`UTF-8`.
|
||||
|
||||
## Examples
|
||||
@ -36,11 +36,11 @@ Hello World
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`base64encode`](/terraform/language/functions/base64encode) performs the opposite operation,
|
||||
* [`base64encode`](/opentf/language/functions/base64encode) performs the opposite operation,
|
||||
encoding the UTF-8 bytes for a string as Base64.
|
||||
* [`textdecodebase64`](/terraform/language/functions/textdecodebase64) is a more general function that
|
||||
* [`textdecodebase64`](/opentf/language/functions/textdecodebase64) is a more general function that
|
||||
supports character encodings other than UTF-8.
|
||||
* [`base64gzip`](/terraform/language/functions/base64gzip) applies gzip compression to a string
|
||||
* [`base64gzip`](/opentf/language/functions/base64gzip) applies gzip compression to a string
|
||||
and returns the result with Base64 encoding.
|
||||
* [`filebase64`](/terraform/language/functions/filebase64) reads a file from the local filesystem
|
||||
* [`filebase64`](/opentf/language/functions/filebase64) reads a file from the local filesystem
|
||||
and returns its raw bytes with Base64 encoding.
|
||||
|
@ -7,25 +7,25 @@ description: The base64encode function applies Base64 encoding to a string.
|
||||
|
||||
`base64encode` applies Base64 encoding to a string.
|
||||
|
||||
Terraform uses the "standard" Base64 alphabet as defined in
|
||||
OpenTF uses the "standard" Base64 alphabet as defined in
|
||||
[RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
|
||||
|
||||
Strings in the Terraform language are sequences of unicode characters rather
|
||||
Strings in the OpenTF language are sequences of unicode characters rather
|
||||
than bytes, so this function will first encode the characters from the string
|
||||
as UTF-8, and then apply Base64 encoding to the result.
|
||||
|
||||
The Terraform language applies Unicode normalization to all strings, and so
|
||||
The OpenTF language applies Unicode normalization to all strings, and so
|
||||
passing a string through `base64decode` and then `base64encode` may not yield
|
||||
the original result exactly.
|
||||
|
||||
While we do not recommend manipulating large, raw binary data in the Terraform
|
||||
While we do not recommend manipulating large, raw binary data in the OpenTF
|
||||
language, Base64 encoding is the standard way to represent arbitrary byte
|
||||
sequences, and so resource types that accept or return binary data will use
|
||||
Base64 themselves, and so this function exists primarily to allow string
|
||||
data to be easily provided to resource types that expect Base64 bytes.
|
||||
|
||||
`base64encode` is, in effect, a shorthand for calling
|
||||
[`textencodebase64`](/terraform/language/functions/textencodebase64) with the encoding name set to
|
||||
[`textencodebase64`](/opentf/language/functions/textencodebase64) with the encoding name set to
|
||||
`UTF-8`.
|
||||
|
||||
## Examples
|
||||
@ -37,12 +37,12 @@ SGVsbG8gV29ybGQ=
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`base64decode`](/terraform/language/functions/base64decode) performs the opposite operation,
|
||||
* [`base64decode`](/opentf/language/functions/base64decode) performs the opposite operation,
|
||||
decoding Base64 data and interpreting it as a UTF-8 string.
|
||||
* [`textencodebase64`](/terraform/language/functions/textencodebase64) is a more general function that
|
||||
* [`textencodebase64`](/opentf/language/functions/textencodebase64) is a more general function that
|
||||
supports character encodings other than UTF-8.
|
||||
* [`base64gzip`](/terraform/language/functions/base64gzip) applies gzip compression to a string
|
||||
* [`base64gzip`](/opentf/language/functions/base64gzip) applies gzip compression to a string
|
||||
and returns the result with Base64 encoding all in one operation.
|
||||
* [`filebase64`](/terraform/language/functions/filebase64) reads a file from the local filesystem
|
||||
* [`filebase64`](/opentf/language/functions/filebase64) reads a file from the local filesystem
|
||||
and returns its raw bytes with Base64 encoding, without creating an
|
||||
intermediate Unicode string.
|
||||
|
@ -10,22 +10,22 @@ description: |-
|
||||
`base64gzip` compresses a string with gzip and then encodes the result in
|
||||
Base64 encoding.
|
||||
|
||||
Terraform uses the "standard" Base64 alphabet as defined in
|
||||
OpenTF uses the "standard" Base64 alphabet as defined in
|
||||
[RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
|
||||
|
||||
Strings in the Terraform language are sequences of unicode characters rather
|
||||
Strings in the OpenTF language are sequences of unicode characters rather
|
||||
than bytes, so this function will first encode the characters from the string
|
||||
as UTF-8, then apply gzip compression, and then finally apply Base64 encoding.
|
||||
|
||||
While we do not recommend manipulating large, raw binary data in the Terraform
|
||||
While we do not recommend manipulating large, raw binary data in the OpenTF
|
||||
language, this function can be used to compress reasonably sized text strings
|
||||
generated within the Terraform language. For example, the result of this
|
||||
generated within the OpenTF language. For example, the result of this
|
||||
function can be used to create a compressed object in Amazon S3 as part of
|
||||
an S3 website.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`base64encode`](/terraform/language/functions/base64encode) applies Base64 encoding _without_
|
||||
* [`base64encode`](/opentf/language/functions/base64encode) applies Base64 encoding _without_
|
||||
gzip compression.
|
||||
* [`filebase64`](/terraform/language/functions/filebase64) reads a file from the local filesystem
|
||||
* [`filebase64`](/opentf/language/functions/filebase64) reads a file from the local filesystem
|
||||
and returns its raw bytes with Base64 encoding.
|
||||
|
@ -13,7 +13,7 @@ returns hexadecimal representation.
|
||||
|
||||
The given string is first encoded as UTF-8 and then the SHA256 algorithm is applied
|
||||
as defined in [RFC 4634](https://tools.ietf.org/html/rfc4634). The raw hash is
|
||||
then encoded with Base64 before returning. Terraform uses the "standard" Base64
|
||||
then encoded with Base64 before returning. OpenTF uses the "standard" Base64
|
||||
alphabet as defined in [RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
|
||||
|
||||
## Examples
|
||||
@ -25,7 +25,7 @@ uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek=
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`filebase64sha256`](/terraform/language/functions/filebase64sha256) calculates the same hash from
|
||||
* [`filebase64sha256`](/opentf/language/functions/filebase64sha256) calculates the same hash from
|
||||
the contents of a file rather than from a string value.
|
||||
* [`sha256`](/terraform/language/functions/sha256) calculates the same hash but returns the result
|
||||
* [`sha256`](/opentf/language/functions/sha256) calculates the same hash but returns the result
|
||||
in a more-verbose hexadecimal encoding.
|
||||
|
@ -13,7 +13,7 @@ returns hexadecimal representation.
|
||||
|
||||
The given string is first encoded as UTF-8 and then the SHA512 algorithm is applied
|
||||
as defined in [RFC 4634](https://tools.ietf.org/html/rfc4634). The raw hash is
|
||||
then encoded with Base64 before returning. Terraform uses the "standard" Base64
|
||||
then encoded with Base64 before returning. OpenTF uses the "standard" Base64
|
||||
alphabet as defined in [RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
|
||||
|
||||
## Examples
|
||||
@ -25,7 +25,7 @@ MJ7MSJwS1utMxA9QyQLytNDtd+5RGnx6m808qG1M2G+YndNbxf9JlnDaNCVbRbDP2DDoH2Bdz33FVC6T
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`filebase64sha512`](/terraform/language/functions/filebase64sha512) calculates the same hash from
|
||||
* [`filebase64sha512`](/opentf/language/functions/filebase64sha512) calculates the same hash from
|
||||
the contents of a file rather than from a string value.
|
||||
* [`sha512`](/terraform/language/functions/sha512) calculates the same hash but returns the result
|
||||
* [`sha512`](/opentf/language/functions/sha512) calculates the same hash but returns the result
|
||||
in a more-verbose hexadecimal encoding.
|
||||
|
@ -24,7 +24,7 @@ it uses backslash `\` as the path segment separator. On Unix systems, the slash
|
||||
Referring directly to filesystem paths in resource arguments may cause
|
||||
spurious diffs if the same configuration is applied from multiple systems or on
|
||||
different host operating systems. We recommend using filesystem paths only
|
||||
for transient values, such as the argument to [`file`](/terraform/language/functions/file) (where
|
||||
for transient values, such as the argument to [`file`](/opentf/language/functions/file) (where
|
||||
only the contents are then stored) or in `connection` and `provisioner` blocks.
|
||||
|
||||
## Examples
|
||||
@ -36,6 +36,6 @@ baz.txt
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`dirname`](/terraform/language/functions/dirname) returns all of the segments of a filesystem path
|
||||
* [`dirname`](/opentf/language/functions/dirname) returns all of the segments of a filesystem path
|
||||
_except_ the last, discarding the portion that would be returned by
|
||||
`basename`.
|
||||
|
@ -26,7 +26,7 @@ blocks, or in data resources whose results are only used in `provisioner`
|
||||
blocks.
|
||||
|
||||
The version prefix on the generated string (e.g. `$2a$`) may change in future
|
||||
versions of Terraform.
|
||||
versions of OpenTF.
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -12,12 +12,12 @@ whether the expression produced a result without any errors.
|
||||
|
||||
This is a special function that is able to catch errors produced when evaluating
|
||||
its argument. For most situations where you could use `can` it's better to use
|
||||
[`try`](/terraform/language/functions/try) instead, because it allows for more concise definition of
|
||||
[`try`](/opentf/language/functions/try) instead, because it allows for more concise definition of
|
||||
fallback values for failing expressions.
|
||||
|
||||
The primary purpose of `can` is to turn an error condition into a boolean
|
||||
validation result when writing
|
||||
[custom variable validation rules](/terraform/language/values/variables#custom-validation-rules).
|
||||
[custom variable validation rules](/opentf/language/values/variables#custom-validation-rules).
|
||||
For example:
|
||||
|
||||
```
|
||||
@ -41,7 +41,7 @@ as a malformed resource reference.
|
||||
variable validation rules. Although it can technically accept any sort of
|
||||
expression and be used elsewhere in the configuration, we recommend against
|
||||
using it in other contexts. For error handling elsewhere in the configuration,
|
||||
prefer to use [`try`](/terraform/language/functions/try).
|
||||
prefer to use [`try`](/opentf/language/functions/try).
|
||||
|
||||
## Examples
|
||||
|
||||
@ -70,5 +70,5 @@ A local value with the name "nonexist" has not been declared.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`try`](/terraform/language/functions/try), which tries evaluating a sequence of expressions and
|
||||
* [`try`](/opentf/language/functions/try), which tries evaluating a sequence of expressions and
|
||||
returns the result of the first one that succeeds.
|
||||
|
@ -21,5 +21,5 @@ given value, which may be a fraction.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`floor`](/terraform/language/functions/floor), which rounds to the nearest whole number _less than_
|
||||
* [`floor`](/opentf/language/functions/floor), which rounds to the nearest whole number _less than_
|
||||
or equal.
|
||||
|
@ -23,5 +23,5 @@ hello
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`trimspace`](/terraform/language/functions/trimspace), which removes all types of whitespace from
|
||||
* [`trimspace`](/opentf/language/functions/trimspace), which removes all types of whitespace from
|
||||
both the start and the end of a string.
|
||||
|
@ -21,7 +21,7 @@ cidrhost(prefix, hostnum)
|
||||
no more than the number of digits remaining in the address after the given
|
||||
prefix. For more details on how this function interprets CIDR prefixes and
|
||||
populates host numbers, see the worked example for
|
||||
[`cidrsubnet`](/terraform/language/functions/cidrsubnet).
|
||||
[`cidrsubnet`](/opentf/language/functions/cidrsubnet).
|
||||
|
||||
Conventionally host number zero is used to represent the address of the
|
||||
network itself and the host number that would fill all the host bits with
|
||||
@ -50,5 +50,5 @@ fd00:fd12:3456:7890::22
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`cidrsubnet`](/terraform/language/functions/cidrsubnet) calculates a subnet address under a given
|
||||
* [`cidrsubnet`](/opentf/language/functions/cidrsubnet) calculates a subnet address under a given
|
||||
network address prefix.
|
||||
|
@ -27,7 +27,7 @@ additional bits added to the prefix.
|
||||
This function accepts both IPv6 and IPv4 prefixes, and the result always uses
|
||||
the same addressing scheme as the given prefix.
|
||||
|
||||
Unlike the related function [`cidrsubnets`](/terraform/language/functions/cidrsubnets), `cidrsubnet`
|
||||
Unlike the related function [`cidrsubnets`](/opentf/language/functions/cidrsubnets), `cidrsubnet`
|
||||
allows you to give a specific network number to use. `cidrsubnets` can allocate
|
||||
multiple network addresses at once, but numbers them automatically starting
|
||||
with zero.
|
||||
@ -93,7 +93,7 @@ This gives us some additional information but also confirms (using a slightly
|
||||
different notation) the conversion from decimal to binary and shows the range
|
||||
of possible host addresses in this network.
|
||||
|
||||
While [`cidrhost`](/terraform/language/functions/cidrhost) allows calculating single host IP addresses,
|
||||
While [`cidrhost`](/opentf/language/functions/cidrhost) allows calculating single host IP addresses,
|
||||
`cidrsubnet` on the other hand creates a new network prefix _within_ the given
|
||||
network prefix. In other words, it creates a subnet.
|
||||
|
||||
@ -148,7 +148,7 @@ Hosts/Net: 14 Class A, Private Internet
|
||||
The new subnet has four bits available for host numbering, which means
|
||||
that there are 14 host addresses available for assignment once we subtract
|
||||
the network's own address and the broadcast address. You can thus use
|
||||
[`cidrhost`](/terraform/language/functions/cidrhost) function to calculate those host addresses by
|
||||
[`cidrhost`](/opentf/language/functions/cidrhost) function to calculate those host addresses by
|
||||
providing it a value between 1 and 14:
|
||||
|
||||
```
|
||||
@ -163,9 +163,9 @@ For more information on CIDR notation and subnetting, see
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`cidrhost`](/terraform/language/functions/cidrhost) calculates the IP address for a single host
|
||||
* [`cidrhost`](/opentf/language/functions/cidrhost) calculates the IP address for a single host
|
||||
within a given network address prefix.
|
||||
* [`cidrnetmask`](/terraform/language/functions/cidrnetmask) converts an IPv4 network prefix in CIDR
|
||||
* [`cidrnetmask`](/opentf/language/functions/cidrnetmask) converts an IPv4 network prefix in CIDR
|
||||
notation into netmask notation.
|
||||
* [`cidrsubnets`](/terraform/language/functions/cidrsubnets) can allocate multiple consecutive
|
||||
* [`cidrsubnets`](/opentf/language/functions/cidrsubnets) can allocate multiple consecutive
|
||||
addresses under a prefix at once, numbering them automatically.
|
||||
|
@ -23,7 +23,7 @@ value is therefore a list with one element per `newbits` argument, each
|
||||
a string containing an address range in CIDR notation.
|
||||
|
||||
For more information on IP addressing concepts, see the documentation for the
|
||||
related function [`cidrsubnet`](/terraform/language/functions/cidrsubnet). `cidrsubnet` calculates
|
||||
related function [`cidrsubnet`](/opentf/language/functions/cidrsubnet). `cidrsubnet` calculates
|
||||
a single subnet address within a prefix while allowing you to specify its
|
||||
subnet number, while `cidrsubnets` can calculate many at once, potentially of
|
||||
different sizes, and assigns subnet numbers automatically.
|
||||
@ -42,7 +42,7 @@ octets that have leading zeros as decimal numbers, which is contrary to some
|
||||
other systems which interpret them as octal. We have preserved this behavior
|
||||
for backward compatibility, but recommend against relying on this behavior.
|
||||
|
||||
-> **Note:** [The Terraform module `hashicorp/subnets/cidr`](https://registry.terraform.io/modules/hashicorp/subnets/cidr)
|
||||
-> **Note:** [The `hashicorp/subnets/cidr` module](https://registry.terraform.io/modules/hashicorp/subnets/cidr)
|
||||
wraps `cidrsubnets` to provide additional functionality for assigning symbolic
|
||||
names to your networks and skipping prefixes for obsolete allocations. Its
|
||||
documentation includes usage examples for several popular cloud virtual network
|
||||
@ -69,7 +69,7 @@ platforms.
|
||||
```
|
||||
|
||||
You can use nested `cidrsubnets` calls with
|
||||
[`for` expressions](/terraform/language/expressions/for)
|
||||
[`for` expressions](/opentf/language/expressions/for)
|
||||
to concisely allocate groups of network address blocks:
|
||||
|
||||
```
|
||||
@ -96,9 +96,9 @@ to concisely allocate groups of network address blocks:
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`cidrhost`](/terraform/language/functions/cidrhost) calculates the IP address for a single host
|
||||
* [`cidrhost`](/opentf/language/functions/cidrhost) calculates the IP address for a single host
|
||||
within a given network address prefix.
|
||||
* [`cidrnetmask`](/terraform/language/functions/cidrnetmask) converts an IPv4 network prefix in CIDR
|
||||
* [`cidrnetmask`](/opentf/language/functions/cidrnetmask) converts an IPv4 network prefix in CIDR
|
||||
notation into netmask notation.
|
||||
* [`cidrsubnet`](/terraform/language/functions/cidrsubnet) calculates a single subnet address, allowing
|
||||
* [`cidrsubnet`](/opentf/language/functions/cidrsubnet) calculates a single subnet address, allowing
|
||||
you to specify its network number.
|
||||
|
@ -10,7 +10,7 @@ description: |-
|
||||
`coalesce` takes any number of arguments and returns the first one
|
||||
that isn't null or an empty string.
|
||||
|
||||
All of the arguments must be of the same type. Terraform will try to
|
||||
All of the arguments must be of the same type. OpenTF will try to
|
||||
convert mismatched arguments to the most general of the types that all
|
||||
arguments can convert to, or return an error if the types are incompatible.
|
||||
The result type is the same as the type of all of the arguments.
|
||||
@ -34,9 +34,9 @@ symbol to expand the list as arguments:
|
||||
b
|
||||
```
|
||||
|
||||
Terraform attempts to select a result type that all of the arguments can
|
||||
OpenTF attempts to select a result type that all of the arguments can
|
||||
convert to, so mixing argument types may produce surprising results due to
|
||||
Terraform's automatic type conversion rules:
|
||||
OpenTF's automatic type conversion rules:
|
||||
|
||||
```
|
||||
> coalesce(1, "hello")
|
||||
@ -52,5 +52,5 @@ Call to function "coalesce" failed: all arguments must have the same type.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`coalescelist`](/terraform/language/functions/coalescelist) performs a similar operation with
|
||||
* [`coalescelist`](/opentf/language/functions/coalescelist) performs a similar operation with
|
||||
list arguments rather than individual arguments.
|
||||
|
@ -38,5 +38,5 @@ symbol to expand the outer list as arguments:
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`coalesce`](/terraform/language/functions/coalesce) performs a similar operation with string
|
||||
* [`coalesce`](/opentf/language/functions/coalesce) performs a similar operation with string
|
||||
arguments rather than list arguments.
|
||||
|
@ -39,7 +39,7 @@ number of fields, or this function will produce an error.
|
||||
## Use with the `for_each` meta-argument
|
||||
|
||||
You can use the result of `csvdecode` with
|
||||
[the `for_each` meta-argument](/terraform/language/meta-arguments/for_each)
|
||||
[the `for_each` meta-argument](/opentf/language/meta-arguments/for_each)
|
||||
to describe a collection of similar objects whose differences are
|
||||
described by the rows in the given CSV file.
|
||||
|
||||
@ -72,22 +72,22 @@ resource "aws_instance" "example" {
|
||||
|
||||
The `for` expression in our `for_each` argument transforms the list produced
|
||||
by `csvdecode` into a map using the `local_id` as a key, which tells
|
||||
Terraform to use the `local_id` value to track each instance it creates.
|
||||
Terraform will create and manage the following instance addresses:
|
||||
OpenTF to use the `local_id` value to track each instance it creates.
|
||||
OpenTF will create and manage the following instance addresses:
|
||||
|
||||
- `aws_instance.example["foo1"]`
|
||||
- `aws_instance.example["foo2"]`
|
||||
- `aws_instance.example["foo3"]`
|
||||
- `aws_instance.example["bar1"]`
|
||||
|
||||
If you modify a row in the CSV on a subsequent plan, Terraform will interpret
|
||||
If you modify a row in the CSV on a subsequent plan, OpenTF will interpret
|
||||
that as an update to the existing object as long as the `local_id` value is
|
||||
unchanged. If you add or remove rows from the CSV then Terraform will plan to
|
||||
unchanged. If you add or remove rows from the CSV then OpenTF will plan to
|
||||
create or destroy associated instances as appropriate.
|
||||
|
||||
If there is no reasonable value you can use as a unique identifier in your CSV
|
||||
then you could instead use
|
||||
[the `count` meta-argument](/terraform/language/meta-arguments/count)
|
||||
[the `count` meta-argument](/opentf/language/meta-arguments/count)
|
||||
to define an object for each CSV row, with each one identified by its index into
|
||||
the list returned by `csvdecode`. However, in that case any future updates to
|
||||
the CSV may be disruptive if they change the positions of particular objects in
|
||||
|
@ -23,7 +23,7 @@ any slashes in the given path will be replaced by backslashes before returning.
|
||||
Referring directly to filesystem paths in resource arguments may cause
|
||||
spurious diffs if the same configuration is applied from multiple systems or on
|
||||
different host operating systems. We recommend using filesystem paths only
|
||||
for transient values, such as the argument to [`file`](/terraform/language/functions/file) (where
|
||||
for transient values, such as the argument to [`file`](/opentf/language/functions/file) (where
|
||||
only the contents are then stored) or in `connection` and `provisioner` blocks.
|
||||
|
||||
## Examples
|
||||
@ -35,5 +35,5 @@ foo/bar
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`basename`](/terraform/language/functions/basename) returns _only_ the last portion of a filesystem
|
||||
* [`basename`](/opentf/language/functions/basename) returns _only_ the last portion of a filesystem
|
||||
path, discarding the portion that would be returned by `dirname`.
|
||||
|
@ -32,7 +32,7 @@ If the given index is greater than the length of the list then the index is
|
||||
a
|
||||
```
|
||||
|
||||
To get the last element from the list use [`length`](/terraform/language/functions/length) to find
|
||||
To get the last element from the list use [`length`](/opentf/language/functions/length) to find
|
||||
the size of the list (minus 1 as the list is zero-based) and then pick the
|
||||
last element:
|
||||
|
||||
@ -43,5 +43,5 @@ c
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`index`](/terraform/language/functions/index_function) finds the index for a particular element value.
|
||||
* [`lookup`](/terraform/language/functions/lookup) retrieves a value from a _map_ given its _key_.
|
||||
* [`index`](/opentf/language/functions/index_function) finds the index for a particular element value.
|
||||
* [`lookup`](/opentf/language/functions/lookup) retrieves a value from a _map_ given its _key_.
|
||||
|
@ -24,4 +24,4 @@ false
|
||||
|
||||
## Related Functions
|
||||
|
||||
- [`startswith`](/terraform/language/functions/startswith) takes two values: a string to check and a prefix string. The function returns true if the string begins with that exact prefix.
|
||||
- [`startswith`](/opentf/language/functions/startswith) takes two values: a string to check and a prefix string. The function returns true if the string begins with that exact prefix.
|
||||
|
@ -14,16 +14,16 @@ a string.
|
||||
file(path)
|
||||
```
|
||||
|
||||
Strings in the Terraform language are sequences of Unicode characters, so
|
||||
Strings in the OpenTF language are sequences of Unicode characters, so
|
||||
this function will interpret the file contents as UTF-8 encoded text and
|
||||
return the resulting Unicode characters. If the file contains invalid UTF-8
|
||||
sequences then this function will produce an error.
|
||||
|
||||
This function can be used only with files that already exist on disk
|
||||
at the beginning of a Terraform run. Functions do not participate in the
|
||||
at the beginning of an OpenTF run. Functions do not participate in the
|
||||
dependency graph, so this function cannot be used with files that are generated
|
||||
dynamically during a Terraform operation. We do not recommend using dynamic
|
||||
local files in Terraform configurations, but in rare situations where this is
|
||||
dynamically during an OpenTF operation. We do not recommend using dynamic
|
||||
local files in OpenTF configurations, but in rare situations where this is
|
||||
necessary you can use
|
||||
[the `local_file` data source](https://registry.terraform.io/providers/hashicorp/local/latest/docs/data-sources/file)
|
||||
to read files while respecting resource dependencies.
|
||||
@ -37,10 +37,10 @@ Hello World
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`filebase64`](/terraform/language/functions/filebase64) also reads the contents of a given file,
|
||||
* [`filebase64`](/opentf/language/functions/filebase64) also reads the contents of a given file,
|
||||
but returns the raw bytes in that file Base64-encoded, rather than
|
||||
interpreting the contents as UTF-8 text.
|
||||
* [`fileexists`](/terraform/language/functions/fileexists) determines whether a file exists
|
||||
* [`fileexists`](/opentf/language/functions/fileexists) determines whether a file exists
|
||||
at a given path.
|
||||
* [`templatefile`](/terraform/language/functions/templatefile) renders using a file from disk as a
|
||||
* [`templatefile`](/opentf/language/functions/templatefile) renders using a file from disk as a
|
||||
template.
|
||||
|
@ -15,19 +15,19 @@ filebase64(path)
|
||||
```
|
||||
|
||||
The result is a Base64 representation of the raw bytes in the given file.
|
||||
Strings in the Terraform language are sequences of Unicode characters, so
|
||||
Strings in the OpenTF language are sequences of Unicode characters, so
|
||||
Base64 is the standard way to represent raw binary data that cannot be
|
||||
interpreted as Unicode characters. Resource types that operate on binary
|
||||
data will accept this data encoded in Base64, thus avoiding the need to
|
||||
decode the result of this function.
|
||||
|
||||
Terraform uses the "standard" Base64 alphabet as defined in
|
||||
OpenTF uses the "standard" Base64 alphabet as defined in
|
||||
[RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
|
||||
|
||||
This function can be used only with functions that already exist as static
|
||||
files on disk at the beginning of a Terraform run. Language functions do not
|
||||
files on disk at the beginning of an OpenTF run. Language functions do not
|
||||
participate in the dependency graph, so this function cannot be used with
|
||||
files that are generated dynamically during a Terraform operation.
|
||||
files that are generated dynamically during an OpenTF operation.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -38,9 +38,9 @@ SGVsbG8gV29ybGQ=
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`file`](/terraform/language/functions/file) also reads the contents of a given file,
|
||||
* [`file`](/opentf/language/functions/file) also reads the contents of a given file,
|
||||
but interprets the data as UTF-8 text and returns the result directly
|
||||
as a string, without any further encoding.
|
||||
* [`base64decode`](/terraform/language/functions/base64decode) can decode a Base64 string representing
|
||||
* [`base64decode`](/opentf/language/functions/base64decode) can decode a Base64 string representing
|
||||
bytes in UTF-8, but in practice `base64decode(filebase64(...))` is equivalent
|
||||
to the shorter expression `file(...)`.
|
||||
|
@ -7,9 +7,9 @@ description: |-
|
||||
|
||||
# `filebase64sha256` Function
|
||||
|
||||
`filebase64sha256` is a variant of [`base64sha256`](/terraform/language/functions/base64sha256)
|
||||
`filebase64sha256` is a variant of [`base64sha256`](/opentf/language/functions/base64sha256)
|
||||
that hashes the contents of a given file rather than a literal string.
|
||||
|
||||
This is similar to `base64sha256(file(filename))`, but
|
||||
because [`file`](/terraform/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
because [`file`](/opentf/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
create hashes for binary files.
|
||||
|
@ -7,9 +7,9 @@ description: |-
|
||||
|
||||
# `filebase64sha512` Function
|
||||
|
||||
`filebase64sha512` is a variant of [`base64sha512`](/terraform/language/functions/base64sha512)
|
||||
`filebase64sha512` is a variant of [`base64sha512`](/opentf/language/functions/base64sha512)
|
||||
that hashes the contents of a given file rather than a literal string.
|
||||
|
||||
This is similar to `base64sha512(file(filename))`, but
|
||||
because [`file`](/terraform/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
because [`file`](/opentf/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
create hashes for binary files.
|
||||
|
@ -13,7 +13,7 @@ fileexists(path)
|
||||
|
||||
Functions are evaluated during configuration parsing rather than at apply time,
|
||||
so this function can only be used with files that are already present on disk
|
||||
before Terraform takes any actions.
|
||||
before OpenTF takes any actions.
|
||||
|
||||
This function works only with regular files. If used with a directory, FIFO,
|
||||
or other special mode, it will return an error.
|
||||
@ -31,4 +31,4 @@ fileexists("custom-section.sh") ? file("custom-section.sh") : local.default_cont
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`file`](/terraform/language/functions/file) reads the contents of a file at a given path
|
||||
* [`file`](/opentf/language/functions/file) reads the contents of a file at a given path
|
||||
|
@ -7,9 +7,9 @@ description: |-
|
||||
|
||||
# `filemd5` Function
|
||||
|
||||
`filemd5` is a variant of [`md5`](/terraform/language/functions/md5)
|
||||
`filemd5` is a variant of [`md5`](/opentf/language/functions/md5)
|
||||
that hashes the contents of a given file rather than a literal string.
|
||||
|
||||
This is similar to `md5(file(filename))`, but
|
||||
because [`file`](/terraform/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
because [`file`](/opentf/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
create hashes for binary files.
|
||||
|
@ -34,7 +34,7 @@ Character classes support the following:
|
||||
|
||||
Functions are evaluated during configuration parsing rather than at apply time,
|
||||
so this function can only be used with files that are already present on disk
|
||||
before Terraform takes any actions.
|
||||
before OpenTF takes any actions.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -66,7 +66,7 @@ before Terraform takes any actions.
|
||||
```
|
||||
|
||||
A common use of `fileset` is to create one resource instance per matched file, using
|
||||
[the `for_each` meta-argument](/terraform/language/meta-arguments/for_each):
|
||||
[the `for_each` meta-argument](/opentf/language/meta-arguments/for_each):
|
||||
|
||||
```hcl
|
||||
resource "example_thing" "example" {
|
||||
|
@ -7,9 +7,9 @@ description: |-
|
||||
|
||||
# `filesha1` Function
|
||||
|
||||
`filesha1` is a variant of [`sha1`](/terraform/language/functions/sha1)
|
||||
`filesha1` is a variant of [`sha1`](/opentf/language/functions/sha1)
|
||||
that hashes the contents of a given file rather than a literal string.
|
||||
|
||||
This is similar to `sha1(file(filename))`, but
|
||||
because [`file`](/terraform/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
because [`file`](/opentf/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
create hashes for binary files.
|
||||
|
@ -7,9 +7,9 @@ description: |-
|
||||
|
||||
# `filesha256` Function
|
||||
|
||||
`filesha256` is a variant of [`sha256`](/terraform/language/functions/sha256)
|
||||
`filesha256` is a variant of [`sha256`](/opentf/language/functions/sha256)
|
||||
that hashes the contents of a given file rather than a literal string.
|
||||
|
||||
This is similar to `sha256(file(filename))`, but
|
||||
because [`file`](/terraform/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
because [`file`](/opentf/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
create hashes for binary files.
|
||||
|
@ -7,9 +7,9 @@ description: |-
|
||||
|
||||
# `filesha512` Function
|
||||
|
||||
`filesha512` is a variant of [`sha512`](/terraform/language/functions/sha512)
|
||||
`filesha512` is a variant of [`sha512`](/opentf/language/functions/sha512)
|
||||
that hashes the contents of a given file rather than a literal string.
|
||||
|
||||
This is similar to `sha512(file(filename))`, but
|
||||
because [`file`](/terraform/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
because [`file`](/opentf/language/functions/file) accepts only UTF-8 text it cannot be used to
|
||||
create hashes for binary files.
|
||||
|
@ -28,9 +28,9 @@ Indirectly-nested lists, such as those in maps, are _not_ flattened.
|
||||
## Flattening nested structures for `for_each`
|
||||
|
||||
The
|
||||
[resource `for_each`](/terraform/language/meta-arguments/for_each)
|
||||
[resource `for_each`](/opentf/language/meta-arguments/for_each)
|
||||
and
|
||||
[`dynamic` block](/terraform/language/expressions/dynamic-blocks)
|
||||
[`dynamic` block](/opentf/language/expressions/dynamic-blocks)
|
||||
language features both require a collection value that has one element for
|
||||
each repetition.
|
||||
|
||||
@ -101,6 +101,6 @@ the associations between the subnets and their containing networks.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`setproduct`](/terraform/language/functions/setproduct) finds all of the combinations of multiple
|
||||
* [`setproduct`](/opentf/language/functions/setproduct) finds all of the combinations of multiple
|
||||
lists or sets of values, which can also be useful when preparing collections
|
||||
for use with `for_each` constructs.
|
||||
|
@ -21,5 +21,5 @@ given value, which may be a fraction.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`ceil`](/terraform/language/functions/ceil), which rounds to the nearest whole number _greater than_
|
||||
* [`ceil`](/opentf/language/functions/ceil), which rounds to the nearest whole number _greater than_
|
||||
or equal.
|
||||
|
@ -34,7 +34,7 @@ Hello, Valentina!
|
||||
Hello, Valentina!
|
||||
```
|
||||
|
||||
The formatting verb `%#v` accepts a value of any type and presents it using JSON encoding, similar to jsonencode. This can be useful for describing the values given to a module in [custom condition check](/terraform/language/expressions/custom-conditions#error-messages) error messages.
|
||||
The formatting verb `%#v` accepts a value of any type and presents it using JSON encoding, similar to jsonencode. This can be useful for describing the values given to a module in [custom condition check](/opentf/language/expressions/custom-conditions#error-messages) error messages.
|
||||
|
||||
```
|
||||
> format("%#v", "hello")
|
||||
@ -96,7 +96,7 @@ The specification may contain the following verbs.
|
||||
|
||||
### Default Format Verbs
|
||||
|
||||
When `%v` is used, Terraform chooses the appropriate format verb based on the value type.
|
||||
When `%v` is used, OpenTF chooses the appropriate format verb based on the value type.
|
||||
|
||||
| Type | Verb |
|
||||
| --------- | ----- |
|
||||
@ -110,7 +110,7 @@ Null values produce the string `null` if formatted with `%v` or `%#v`, and cause
|
||||
### Width Modifier
|
||||
|
||||
Use a width modifier with an optional decimal number immediately
|
||||
preceding the verb letter to specify how many characters will be used to represent the value. You can specify precision after the (optional) width with a period (`.`) followed by a decimal number. If width or precision are omitted, Terraform selects default values based on the given value.
|
||||
preceding the verb letter to specify how many characters will be used to represent the value. You can specify precision after the (optional) width with a period (`.`) followed by a decimal number. If width or precision are omitted, OpenTF selects default values based on the given value.
|
||||
|
||||
The following examples demonstrate example use cases for the width modifier.
|
||||
|
||||
@ -139,7 +139,7 @@ Use the following symbols immediately after the `%` symbol to set additional for
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`formatdate`](/terraform/language/functions/formatdate) is a specialized formatting function for
|
||||
* [`formatdate`](/opentf/language/functions/formatdate) is a specialized formatting function for
|
||||
human-readable timestamps.
|
||||
* [`formatlist`](/terraform/language/functions/formatlist) uses the same specification syntax to
|
||||
* [`formatlist`](/opentf/language/functions/formatlist) uses the same specification syntax to
|
||||
produce a list of strings.
|
||||
|
@ -11,7 +11,7 @@ description: The formatdate function converts a timestamp into a different time
|
||||
formatdate(spec, timestamp)
|
||||
```
|
||||
|
||||
In the Terraform language, timestamps are conventionally represented as
|
||||
In the OpenTF language, timestamps are conventionally represented as
|
||||
strings using [RFC 3339](https://tools.ietf.org/html/rfc3339)
|
||||
"Date and Time format" syntax. `formatdate` requires the `timestamp` argument
|
||||
to be a string conforming to this syntax.
|
||||
@ -99,7 +99,7 @@ configuration as needed:
|
||||
|
||||
## Related Functions
|
||||
|
||||
- [`format`](/terraform/language/functions/format) is a more general formatting function for arbitrary
|
||||
- [`format`](/opentf/language/functions/format) is a more general formatting function for arbitrary
|
||||
data.
|
||||
- [`timestamp`](/terraform/language/functions/timestamp) returns the current date and time in a format
|
||||
- [`timestamp`](/opentf/language/functions/timestamp) returns the current date and time in a format
|
||||
suitable for input to `formatdate`.
|
||||
|
@ -15,7 +15,7 @@ formatlist(spec, values...)
|
||||
```
|
||||
|
||||
The specification string uses
|
||||
[the same syntax as `format`](/terraform/language/functions/format#specification-syntax).
|
||||
[the same syntax as `format`](/opentf/language/functions/format#specification-syntax).
|
||||
|
||||
The given values can be a mixture of list and non-list arguments. Any given
|
||||
lists must be the same length, which decides the length of the resulting list.
|
||||
@ -45,5 +45,5 @@ once per element of the list arguments.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`format`](/terraform/language/functions/format) defines the specification syntax used by this
|
||||
* [`format`](/opentf/language/functions/format) defines the specification syntax used by this
|
||||
function and produces a single string as its result.
|
||||
|
@ -7,9 +7,7 @@ description: >-
|
||||
|
||||
# Built-in Functions
|
||||
|
||||
> **Hands-on:** Try the [Perform Dynamic Operations with Functions](/terraform/tutorials/configuration-language/functions?utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) tutorial.
|
||||
|
||||
The Terraform language includes a number of built-in functions that you can
|
||||
The OpenTF language includes a number of built-in functions that you can
|
||||
call from within expressions to transform and combine values. The general
|
||||
syntax for function calls is a function name followed by comma-separated
|
||||
arguments in parentheses:
|
||||
@ -19,15 +17,15 @@ max(5, 12, 9)
|
||||
```
|
||||
|
||||
For more details on syntax, see
|
||||
[_Function Calls_](/terraform/language/expressions/function-calls)
|
||||
[_Function Calls_](/opentf/language/expressions/function-calls)
|
||||
in the Expressions section.
|
||||
|
||||
The Terraform language does not support user-defined functions, and so only
|
||||
The OpenTF language does not support user-defined functions, and so only
|
||||
the functions built in to the language are available for use. The documentation includes a page for all of the available built-in functions.
|
||||
|
||||
You can experiment with the behavior of Terraform's built-in functions from
|
||||
the Terraform expression console, by running
|
||||
[the `terraform console` command](/terraform/cli/commands/console):
|
||||
You can experiment with the behavior of OpenTF's built-in functions from
|
||||
the OpenTF expression console, by running
|
||||
[the `opentf console` command](/opentf/cli/commands/console):
|
||||
|
||||
```
|
||||
> max(5, 12, 9)
|
||||
|
@ -23,5 +23,5 @@ value is not present in the list.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`element`](/terraform/language/functions/element) retrieves a particular element from a list given
|
||||
* [`element`](/opentf/language/functions/element) retrieves a particular element from a list given
|
||||
its index.
|
||||
|
@ -27,5 +27,5 @@ foo
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`split`](/terraform/language/functions/split) performs the opposite operation: producing a list
|
||||
* [`split`](/opentf/language/functions/split) performs the opposite operation: producing a list
|
||||
by separating a single string using a given delimiter.
|
||||
|
@ -13,19 +13,19 @@ of the result of decoding that string.
|
||||
The JSON encoding is defined in [RFC 7159](https://tools.ietf.org/html/rfc7159).
|
||||
|
||||
This function maps JSON values to
|
||||
[Terraform language values](/terraform/language/expressions/types)
|
||||
[OpenTF language values](/opentf/language/expressions/types)
|
||||
in the following way:
|
||||
|
||||
| JSON type | Terraform type |
|
||||
| JSON type | OpenTF type |
|
||||
| --------- | ------------------------------------------------------------ |
|
||||
| String | `string` |
|
||||
| Number | `number` |
|
||||
| Boolean | `bool` |
|
||||
| Object | `object(...)` with attribute types determined per this table |
|
||||
| Array | `tuple(...)` with element types determined per this table |
|
||||
| Null | The Terraform language `null` value |
|
||||
| Null | The OpenTF language `null` value |
|
||||
|
||||
The Terraform language automatic type conversion rules mean that you don't
|
||||
The OpenTF language automatic type conversion rules mean that you don't
|
||||
usually need to worry about exactly what type is produced for a given value,
|
||||
and can just use the result in an intuitive way.
|
||||
|
||||
@ -42,5 +42,5 @@ true
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`jsonencode`](/terraform/language/functions/jsonencode) performs the opposite operation, _encoding_
|
||||
* [`jsonencode`](/opentf/language/functions/jsonencode) performs the opposite operation, _encoding_
|
||||
a value as JSON.
|
||||
|
@ -10,10 +10,10 @@ description: The jsonencode function encodes a given value as a JSON string.
|
||||
The JSON encoding is defined in [RFC 7159](https://tools.ietf.org/html/rfc7159).
|
||||
|
||||
This function maps
|
||||
[Terraform language values](/terraform/language/expressions/types)
|
||||
[OpenTF language values](/opentf/language/expressions/types)
|
||||
to JSON values in the following way:
|
||||
|
||||
| Terraform type | JSON type |
|
||||
| OpenTF type | JSON type |
|
||||
| -------------- | --------- |
|
||||
| `string` | String |
|
||||
| `number` | Number |
|
||||
@ -25,15 +25,14 @@ to JSON values in the following way:
|
||||
| `object(...)` | Object |
|
||||
| Null value | `null` |
|
||||
|
||||
Since the JSON format cannot fully represent all of the Terraform language
|
||||
Since the JSON format cannot fully represent all of the OpenTF language
|
||||
types, passing the `jsonencode` result to `jsondecode` will not produce an
|
||||
identical value, but the automatic type conversion rules mean that this is
|
||||
rarely a problem in practice.
|
||||
|
||||
When encoding strings, this function escapes some characters using
|
||||
Unicode escape sequences: replacing `<`, `>`, `&`, `U+2028`, and `U+2029` with
|
||||
`\u003c`, `\u003e`, `\u0026`, `\u2028`, and `\u2029`. This is to preserve
|
||||
compatibility with Terraform 0.11 behavior.
|
||||
`\u003c`, `\u003e`, `\u0026`, `\u2028`, and `\u2029`.
|
||||
|
||||
The `jsonencode` command outputs a minified representation of the input.
|
||||
|
||||
@ -46,5 +45,5 @@ The `jsonencode` command outputs a minified representation of the input.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`jsondecode`](/terraform/language/functions/jsondecode) performs the opposite operation, _decoding_
|
||||
* [`jsondecode`](/opentf/language/functions/jsondecode) performs the opposite operation, _decoding_
|
||||
a JSON string to obtain its represented value.
|
||||
|
@ -23,4 +23,4 @@ be identical as long as the keys in the map don't change.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`values`](/terraform/language/functions/values) returns a list of the _values_ from a map.
|
||||
* [`values`](/opentf/language/functions/values) returns a list of the _values_ from a map.
|
||||
|
@ -34,6 +34,6 @@ number of bytes or Unicode sequences that form them:
|
||||
A "character" is a _grapheme cluster_, as defined by
|
||||
[Unicode Standard Annex #29](http://unicode.org/reports/tr29/). Note that
|
||||
remote APIs may have a different definition of "character" for the purpose of
|
||||
length limits on string arguments; a Terraform provider is responsible for
|
||||
translating Terraform's string representation into that used by its respective
|
||||
length limits on string arguments; an OpenTF provider is responsible for
|
||||
translating OpenTF's string representation into that used by its respective
|
||||
remote system and applying any additional validation rules to it.
|
||||
|
@ -1,26 +0,0 @@
|
||||
---
|
||||
page_title: list - Functions - Configuration Language
|
||||
description: The list function constructs a list from some given elements.
|
||||
---
|
||||
|
||||
# `list` Function
|
||||
|
||||
The `list` function is no longer available. Prior to Terraform v0.12 it was
|
||||
the only available syntax for writing a literal list inside an expression,
|
||||
but Terraform v0.12 introduced a new first-class syntax.
|
||||
|
||||
To update an expression like `list(a, b, c)`, write the following instead:
|
||||
|
||||
```
|
||||
tolist([a, b, c])
|
||||
```
|
||||
|
||||
The `[ ... ]` brackets construct a tuple value, and then the `tolist` function
|
||||
then converts it to a list. For more information on the value types in the
|
||||
Terraform language, see [Type Constraints](/terraform/language/expressions/types).
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`concat`](/terraform/language/functions/concat) produces a new list by concatenating together the
|
||||
elements from other lists.
|
||||
* [`tolist`](/terraform/language/functions/tolist) converts a set or tuple value to a list.
|
@ -27,4 +27,4 @@ what?
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`element`](/terraform/language/functions/element) retrieves a value from a _list_ given its _index_.
|
||||
* [`element`](/opentf/language/functions/element) retrieves a value from a _list_ given its _index_.
|
||||
|
@ -22,5 +22,5 @@ This function uses Unicode's definition of letters and of upper- and lowercase.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`upper`](/terraform/language/functions/upper) converts letters in a string to _uppercase_.
|
||||
* [`title`](/terraform/language/functions/title) converts the first letter of each word in a string to uppercase.
|
||||
* [`upper`](/opentf/language/functions/upper) converts letters in a string to _uppercase_.
|
||||
* [`title`](/opentf/language/functions/title) converts the first letter of each word in a string to uppercase.
|
||||
|
@ -1,29 +0,0 @@
|
||||
---
|
||||
page_title: map - Functions - Configuration Language
|
||||
description: The map function constructs a map from some given elements.
|
||||
---
|
||||
|
||||
# `map` Function
|
||||
|
||||
The `map` function is no longer available. Prior to Terraform v0.12 it was
|
||||
the only available syntax for writing a literal map inside an expression,
|
||||
but Terraform v0.12 introduced a new first-class syntax.
|
||||
|
||||
To update an expression like `map("a", "b", "c", "d")`, write the following instead:
|
||||
|
||||
```
|
||||
tomap({
|
||||
a = "b"
|
||||
c = "d"
|
||||
})
|
||||
```
|
||||
|
||||
The `{ ... }` braces construct an object value, and then the `tomap` function
|
||||
then converts it to a map. For more information on the value types in the
|
||||
Terraform language, see [Type Constraints](/terraform/language/expressions/types).
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`tomap`](/terraform/language/functions/tomap) converts an object value to a map.
|
||||
* [`zipmap`](/terraform/language/functions/zipmap) constructs a map dynamically, by taking keys from
|
||||
one list and values from another list.
|
@ -24,4 +24,4 @@ to individual arguments:
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`min`](/terraform/language/functions/min), which returns the _smallest_ number from a set.
|
||||
* [`min`](/opentf/language/functions/min), which returns the _smallest_ number from a set.
|
||||
|
@ -27,5 +27,5 @@ considerations applying to the MD5 algorithm.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`filemd5`](/terraform/language/functions/filemd5) calculates the same hash from
|
||||
* [`filemd5`](/opentf/language/functions/filemd5) calculates the same hash from
|
||||
the contents of a file rather than from a string value.
|
||||
|
@ -39,7 +39,7 @@ type structure of the attributes after the merging rules have been applied.
|
||||
}
|
||||
```
|
||||
|
||||
The following example uses the expansion symbol (...) to transform the value into separate arguments. Refer to [Expanding Function Argument](/terraform/language/expressions/function-calls#expanding-function-arguments) for details.
|
||||
The following example uses the expansion symbol (...) to transform the value into separate arguments. Refer to [Expanding Function Argument](/opentf/language/expressions/function-calls#expanding-function-arguments) for details.
|
||||
|
||||
```
|
||||
> merge([{a="b", c="d"}, {}, {e="f", c="z"}]...)
|
||||
|
@ -24,4 +24,4 @@ to individual arguments:
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`max`](/terraform/language/functions/max), which returns the _greatest_ number from a set.
|
||||
* [`max`](/opentf/language/functions/max), which returns the _greatest_ number from a set.
|
||||
|
@ -2,31 +2,29 @@
|
||||
page_title: nonsensitive - Functions - Configuration Language
|
||||
description: >-
|
||||
The nonsensitive function removes the sensitive marking from a value that
|
||||
Terraform considers to be sensitive.
|
||||
OpenTF considers to be sensitive.
|
||||
---
|
||||
|
||||
# `nonsensitive` Function
|
||||
|
||||
-> **Note:** This function is only available in Terraform v0.15 and later.
|
||||
|
||||
`nonsensitive` takes a sensitive value and returns a copy of that value with
|
||||
the sensitive marking removed, thereby exposing the sensitive value.
|
||||
|
||||
~> **Warning:** Using this function indiscriminately will cause values that
|
||||
Terraform would normally have considered as sensitive to be treated as normal
|
||||
values and shown clearly in Terraform's output. Use this function only when
|
||||
OpenTF would normally have considered as sensitive to be treated as normal
|
||||
values and shown clearly in OpenTF's output. Use this function only when
|
||||
you've derived a new value from a sensitive value in a way that eliminates the
|
||||
sensitive portions of the value.
|
||||
|
||||
Normally Terraform tracks when you use expressions to derive a new value from
|
||||
Normally OpenTF tracks when you use expressions to derive a new value from
|
||||
a value that is marked as sensitive, so that the result can also be marked
|
||||
as sensitive.
|
||||
|
||||
However, you may wish to write expressions that derive non-sensitive results
|
||||
from sensitive values. For example, if you know based on details of your
|
||||
particular system and its threat model that a SHA256 hash of a particular
|
||||
sensitive value is safe to include clearly in Terraform output, you could use
|
||||
the `nonsensitive` function to indicate that, overriding Terraform's normal
|
||||
sensitive value is safe to include clearly in OpenTF output, you could use
|
||||
the `nonsensitive` function to indicate that, overriding OpenTF's normal
|
||||
conservative behavior:
|
||||
|
||||
```hcl
|
||||
@ -57,7 +55,7 @@ locals {
|
||||
# username_from_json would normally be considered to be
|
||||
# sensitive too, but system-specific knowledge tells us
|
||||
# that the username is a non-sensitive fragment of the
|
||||
# original document, and so we can override Terraform's
|
||||
# original document, and so we can override OpenTF's
|
||||
# determination.
|
||||
username_from_json = nonsensitive(local.mixed_content["username"])
|
||||
}
|
||||
@ -66,11 +64,11 @@ locals {
|
||||
When you use this function, it's your responsibility to ensure that the
|
||||
expression passed as its argument will remove all sensitive content from
|
||||
the sensitive value it depends on. By passing a value to `nonsensitive` you are
|
||||
declaring to Terraform that you have done all that is necessary to ensure that
|
||||
declaring to OpenTF that you have done all that is necessary to ensure that
|
||||
the resulting value has no sensitive content, even though it was derived
|
||||
from sensitive content. If a sensitive value appears in Terraform's output
|
||||
from sensitive content. If a sensitive value appears in OpenTF's output
|
||||
due to an inappropriate call to `nonsensitive` in your module, that's a bug in
|
||||
your module and not a bug in Terraform itself.
|
||||
your module and not a bug in OpenTF itself.
|
||||
**Use this function sparingly and only with due care.**
|
||||
|
||||
`nonsensitive` will return an error if you pass a value that isn't marked
|
||||
@ -84,7 +82,7 @@ care to preserve under future modifications.
|
||||
|
||||
## Examples
|
||||
|
||||
The following examples are from `terraform console` when running in the
|
||||
The following examples are from `opentf console` when running in the
|
||||
context of the example above with `variable "mixed_content_json"` and
|
||||
the local value `mixed_content`, with a valid JSON string assigned to
|
||||
`var.mixed_content_json`.
|
||||
|
@ -7,8 +7,6 @@ description: |-
|
||||
|
||||
# `one` Function
|
||||
|
||||
-> **Note:** This function is available only in Terraform v0.15 and later.
|
||||
|
||||
`one` takes a list, set, or tuple value with either zero or one elements.
|
||||
If the collection is empty, `one` returns `null`. Otherwise, `one` returns
|
||||
the first element. If there are two or more elements then `one` will return
|
||||
@ -46,8 +44,8 @@ no instances were created.
|
||||
|
||||
## Relationship to the "Splat" Operator
|
||||
|
||||
The Terraform language has a built-in operator `[*]`, known as
|
||||
[the _splat_ operator](/terraform/language/expressions/splat), and one of its functions
|
||||
The OpenTF language has a built-in operator `[*]`, known as
|
||||
[the _splat_ operator](/opentf/language/expressions/splat), and one of its functions
|
||||
is to translate a primitive value that might be null into a list of either
|
||||
zero or one elements:
|
||||
|
||||
|
@ -46,5 +46,5 @@ Invalid value for "number" parameter: cannot parse "12" as a base 2 integer.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`format`](/terraform/language/functions/format) can format numbers and other values into strings,
|
||||
* [`format`](/opentf/language/functions/format) can format numbers and other values into strings,
|
||||
with optional zero padding, alignment, etc.
|
||||
|
@ -30,7 +30,7 @@ depending on host operating system.
|
||||
**For Unix systems**, the following sources are consulted, in order of preference:
|
||||
|
||||
* The `HOME` environment variable.
|
||||
* The result of running `getent passwd` followed by the Terraform process uid.
|
||||
* The result of running `getent passwd` followed by the OpenTF process uid.
|
||||
* The result of running `cd && pwd` in `sh`.
|
||||
|
||||
**For Windows systems**, there is not really the concept of a home directory
|
||||
@ -42,7 +42,7 @@ order of preference:
|
||||
* The `USERPROFILE` environment variable.
|
||||
|
||||
The exact rules employed for each operating system may change in future
|
||||
releases of Terraform.
|
||||
releases of OpenTF.
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -7,26 +7,24 @@ description: |-
|
||||
|
||||
# `plantimestamp` Function
|
||||
|
||||
-> **Note:** This function is only available in Terraform v1.5 and later.
|
||||
|
||||
`plantimestamp` returns a UTC timestamp string in [RFC 3339](https://tools.ietf.org/html/rfc3339) format.
|
||||
|
||||
In the Terraform language, timestamps are conventionally represented as
|
||||
In the OpenTF language, timestamps are conventionally represented as
|
||||
strings using [RFC 3339](https://tools.ietf.org/html/rfc3339)
|
||||
"Date and Time format" syntax, and so `plantimestamp` returns a string
|
||||
in this format.
|
||||
|
||||
The result of this function will change for every plan operation. It is intended
|
||||
for use within [Custom Conditions](/terraform/language/expressions/custom-conditions)
|
||||
for use within [Custom Conditions](/opentf/language/expressions/custom-conditions)
|
||||
as a way to validate time sensitive resources such as TLS certificates.
|
||||
|
||||
There are circumstances, such as during a Terraform [Refresh-only](/terraform/cli/commands/plan#planning-modes) plan, where
|
||||
There are circumstances, such as during an OpenTF [Refresh-only](/opentf/cli/commands/plan#planning-modes) plan, where
|
||||
the value for this function will be recomputed but not propagated to resources
|
||||
defined within the configuration. As such, it is recommended that this function
|
||||
only be used to compare against timestamps exported by providers and not against
|
||||
timestamps generated in the configuration.
|
||||
|
||||
The `plantimestamp` function is not available within the Terraform console.
|
||||
The `plantimestamp` function is not available within the OpenTF console.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -35,7 +33,7 @@ The `plantimestamp` function is not available within the Terraform console.
|
||||
2018-05-13T07:44:12Z
|
||||
```
|
||||
|
||||
```terraform
|
||||
```hcl
|
||||
check "placeholderplaceholderplaceholder_io_certificate" {
|
||||
data "tls_certificate" "placeholderplaceholderplaceholder_io" {
|
||||
url = "https://www.placeholderplaceholderplaceholder.io/"
|
||||
@ -43,12 +41,12 @@ check "placeholderplaceholderplaceholder_io_certificate" {
|
||||
|
||||
assert {
|
||||
condition = timecmp(plantimestamp(), data.tls_certificate.placeholderplaceholderplaceholder_io.certificates[0].not_after) < 0
|
||||
error_message = "terraform.io certificate has expired"
|
||||
error_message = "placeholderplaceholderplaceholder.io certificate has expired"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`timestamp`](/terraform/language/functions/timestamp) returns the current timestamp when it is evaluated
|
||||
during the apply step.
|
||||
* [`timestamp`](/opentf/language/functions/timestamp) returns the current timestamp when it is evaluated
|
||||
during the apply step.
|
||||
|
@ -35,7 +35,7 @@ while num < limit: (or, for negative step, num > limit)
|
||||
return the sequence
|
||||
```
|
||||
|
||||
Because the sequence is created as a physical list in memory, Terraform imposes
|
||||
Because the sequence is created as a physical list in memory, OpenTF imposes
|
||||
an artificial limit of 1024 numbers in the resulting sequence in order to avoid
|
||||
unbounded memory usage if, for example, a very large value were accidentally
|
||||
passed as the limit or a very small value as the step. If the algorithm above
|
||||
|
@ -30,12 +30,12 @@ It's not valid to mix both named and unnamed capture groups in the same pattern.
|
||||
|
||||
If the given pattern does not match at all, the `regex` raises an error. To
|
||||
_test_ whether a given pattern matches a string, use
|
||||
[`regexall`](/terraform/language/functions/regexall) and test that the result has length greater than
|
||||
[`regexall`](/opentf/language/functions/regexall) and test that the result has length greater than
|
||||
zero.
|
||||
|
||||
The pattern is a string containing a mixture of literal characters and special
|
||||
matching operators as described in the following table. Note that when giving a
|
||||
regular expression pattern as a literal quoted string in the Terraform
|
||||
regular expression pattern as a literal quoted string in the OpenTF
|
||||
language, the quoted string itself already uses backslash `\` as an escape
|
||||
character for the string, so any backslashes intended to be recognized as part
|
||||
of the pattern must be escaped as `\\`.
|
||||
@ -102,7 +102,7 @@ no characters. These are "zero-width" matching operators:
|
||||
| `\b` | At an ASCII word boundary (transition between `\w` and either `\W`, `\A` or `\z`, or vice-versa) |
|
||||
| `\B` | Not at an ASCII word boundary |
|
||||
|
||||
Terraform uses the
|
||||
OpenTF uses the
|
||||
[RE2](https://github.com/google/re2/wiki/Syntax) regular expression language.
|
||||
This engine does not support all of the features found in some other regular
|
||||
expression engines; in particular, it does not support backreferences.
|
||||
@ -136,9 +136,9 @@ aaabbbccc
|
||||
"01",
|
||||
]
|
||||
|
||||
> regex("^(?:(?P<scheme>[^:/?#]+):)?(?://(?P<authority>[^/?#]*))?", "https://terraform.io/docs/")
|
||||
> regex("^(?:(?P<scheme>[^:/?#]+):)?(?://(?P<authority>[^/?#]*))?", "https://example.com/docs/")
|
||||
{
|
||||
"authority" = "terraform.io"
|
||||
"authority" = "example.com"
|
||||
"scheme" = "https"
|
||||
}
|
||||
|
||||
@ -152,10 +152,10 @@ string.
|
||||
|
||||
## Related Functions
|
||||
|
||||
- [`regexall`](/terraform/language/functions/regexall) searches for potentially multiple matches of a given pattern in a string.
|
||||
- [`replace`](/terraform/language/functions/replace) replaces a substring of a string with another string, optionally matching using the same regular expression syntax as `regex`.
|
||||
- [`regexall`](/opentf/language/functions/regexall) searches for potentially multiple matches of a given pattern in a string.
|
||||
- [`replace`](/opentf/language/functions/replace) replaces a substring of a string with another string, optionally matching using the same regular expression syntax as `regex`.
|
||||
|
||||
If Terraform already has a more specialized function to parse the syntax you
|
||||
If OpenTF already has a more specialized function to parse the syntax you
|
||||
are trying to match, prefer to use that function instead. Regular expressions
|
||||
can be hard to read and can obscure your intent, making a configuration harder
|
||||
to read and understand.
|
||||
|
@ -15,7 +15,7 @@ to a string and returns a list of all matches.
|
||||
regexall(pattern, string)
|
||||
```
|
||||
|
||||
`regexall` is a variant of [`regex`](/terraform/language/functions/regex) and uses the same pattern
|
||||
`regexall` is a variant of [`regex`](/opentf/language/functions/regex) and uses the same pattern
|
||||
syntax. For any given input to `regex`, `regexall` returns a list of whatever
|
||||
type `regex` would've returned, with one element per match. That is:
|
||||
|
||||
@ -48,10 +48,10 @@ false
|
||||
|
||||
## Related Functions
|
||||
|
||||
- [`regex`](/terraform/language/functions/regex) searches for a single match of a given pattern, and
|
||||
- [`regex`](/opentf/language/functions/regex) searches for a single match of a given pattern, and
|
||||
returns an error if no match is found.
|
||||
|
||||
If Terraform already has a more specialized function to parse the syntax you
|
||||
If OpenTF already has a more specialized function to parse the syntax you
|
||||
are trying to match, prefer to use that function instead. Regular expressions
|
||||
can be hard to read and can obscure your intent, making a configuration harder
|
||||
to read and understand.
|
||||
|
@ -16,7 +16,7 @@ replace(string, substring, replacement)
|
||||
|
||||
If `substring` is wrapped in forward slashes, it is treated as a regular
|
||||
expression, using the same pattern syntax as
|
||||
[`regex`](/terraform/language/functions/regex). If using a regular expression for the substring
|
||||
[`regex`](/opentf/language/functions/regex). If using a regular expression for the substring
|
||||
argument, the `replacement` string can incorporate captured strings from
|
||||
the input by using an `$n` sequence, where `n` is the index or name of a
|
||||
capture group.
|
||||
@ -33,5 +33,5 @@ hello everybody
|
||||
|
||||
## Related Functions
|
||||
|
||||
- [`regex`](/terraform/language/functions/regex) searches a given string for a substring matching a
|
||||
- [`regex`](/opentf/language/functions/regex) searches a given string for a substring matching a
|
||||
given regular expression pattern.
|
||||
|
@ -21,4 +21,4 @@ with all of the same elements as the given sequence but in reverse order.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`strrev`](/terraform/language/functions/strrev) reverses a string.
|
||||
* [`strrev`](/opentf/language/functions/strrev) reverses a string.
|
||||
|
@ -13,13 +13,13 @@ rsadecrypt(ciphertext, privatekey)
|
||||
```
|
||||
|
||||
`ciphertext` must be a base64-encoded representation of the ciphertext, using
|
||||
the PKCS #1 v1.5 padding scheme. Terraform uses the "standard" Base64 alphabet
|
||||
the PKCS #1 v1.5 padding scheme. OpenTF uses the "standard" Base64 alphabet
|
||||
as defined in [RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
|
||||
|
||||
`privatekey` must be a PEM-encoded RSA private key that is not itself
|
||||
encrypted.
|
||||
|
||||
Terraform has no corresponding function for _encrypting_ a message. Use this
|
||||
OpenTF has no corresponding function for _encrypting_ a message. Use this
|
||||
function to decrypt ciphertexts returned by remote services using a keypair
|
||||
negotiated out-of-band.
|
||||
|
||||
|
@ -5,16 +5,14 @@ description: The sensitive function marks a value as being sensitive.
|
||||
|
||||
# `sensitive` Function
|
||||
|
||||
-> **Note:** This function is only available in Terraform v0.15 and later.
|
||||
|
||||
`sensitive` takes any value and returns a copy of it marked so that Terraform
|
||||
`sensitive` takes any value and returns a copy of it marked so that OpenTF
|
||||
will treat it as sensitive, with the same meaning and behavior as for
|
||||
[sensitive input variables](/terraform/language/values/variables#suppressing-values-in-cli-output).
|
||||
[sensitive input variables](/opentf/language/values/variables#suppressing-values-in-cli-output).
|
||||
|
||||
Wherever possible we recommend marking your input variable and/or output value
|
||||
declarations as sensitive directly, instead of using this function, because in
|
||||
that case you can be sure that there is no way to refer to those values without
|
||||
Terraform automatically considering them as sensitive.
|
||||
OpenTF automatically considering them as sensitive.
|
||||
|
||||
The `sensitive` function might be useful in some less-common situations where a
|
||||
sensitive value arises from a definition _within_ your module, such as if you've
|
||||
@ -28,7 +26,7 @@ locals {
|
||||
|
||||
However, we generally don't recommend writing sensitive values directly within
|
||||
your module any of the files you distribute statically as part of that module,
|
||||
because they may be exposed in other ways outside of Terraform's control.
|
||||
because they may be exposed in other ways outside of OpenTF's control.
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -30,10 +30,10 @@ the ordering of the given elements is not preserved.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`contains`](/terraform/language/functions/contains) tests whether a given list or set contains
|
||||
* [`contains`](/opentf/language/functions/contains) tests whether a given list or set contains
|
||||
a given element value.
|
||||
* [`setproduct`](/terraform/language/functions/setproduct) computes the _Cartesian product_ of multiple
|
||||
* [`setproduct`](/opentf/language/functions/setproduct) computes the _Cartesian product_ of multiple
|
||||
sets.
|
||||
* [`setsubtract`](/terraform/language/functions/setsubtract) computes the _relative complement_ of two sets
|
||||
* [`setunion`](/terraform/language/functions/setunion) computes the _union_ of
|
||||
* [`setsubtract`](/opentf/language/functions/setsubtract) computes the _relative complement_ of two sets
|
||||
* [`setunion`](/opentf/language/functions/setunion) computes the _union_ of
|
||||
multiple sets.
|
||||
|
@ -85,7 +85,7 @@ only one element, which is the first element of each argument:
|
||||
```
|
||||
|
||||
Each argument must have a consistent type for all of its elements. If not,
|
||||
Terraform will attempt to convert to the most general type, or produce an
|
||||
OpenTF will attempt to convert to the most general type, or produce an
|
||||
error if such a conversion is impossible. For example, mixing both strings and
|
||||
numbers results in the numbers being converted to strings so that the result
|
||||
elements all have a consistent type:
|
||||
@ -115,9 +115,9 @@ elements all have a consistent type:
|
||||
## Finding combinations for `for_each`
|
||||
|
||||
The
|
||||
[resource `for_each`](/terraform/language/meta-arguments/for_each)
|
||||
[resource `for_each`](/opentf/language/meta-arguments/for_each)
|
||||
and
|
||||
[`dynamic` block](/terraform/language/expressions/dynamic-blocks)
|
||||
[`dynamic` block](/opentf/language/expressions/dynamic-blocks)
|
||||
language features both require a collection value that has one element for
|
||||
each repetition.
|
||||
|
||||
@ -269,13 +269,13 @@ The `network_subnets` output would look similar to the following:
|
||||
|
||||
## Related Functions
|
||||
|
||||
- [`contains`](/terraform/language/functions/contains) tests whether a given list or set contains
|
||||
- [`contains`](/opentf/language/functions/contains) tests whether a given list or set contains
|
||||
a given element value.
|
||||
- [`flatten`](/terraform/language/functions/flatten) is useful for flattening hierarchical data
|
||||
- [`flatten`](/opentf/language/functions/flatten) is useful for flattening hierarchical data
|
||||
into a single list, for situations where the relationships between two
|
||||
object types are defined explicitly.
|
||||
- [`setintersection`](/terraform/language/functions/setintersection) computes the _intersection_ of
|
||||
- [`setintersection`](/opentf/language/functions/setintersection) computes the _intersection_ of
|
||||
multiple sets.
|
||||
- [`setsubtract`](/terraform/language/functions/setsubtract) computes the _relative complement_ of two sets
|
||||
- [`setunion`](/terraform/language/functions/setunion) computes the _union_ of multiple
|
||||
- [`setsubtract`](/opentf/language/functions/setsubtract) computes the _relative complement_ of two sets
|
||||
- [`setunion`](/opentf/language/functions/setunion) computes the _union_ of multiple
|
||||
sets.
|
||||
|
@ -35,8 +35,8 @@ toset([
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`setintersection`](/terraform/language/functions/setintersection) computes the _intersection_ of multiple sets
|
||||
* [`setproduct`](/terraform/language/functions/setproduct) computes the _Cartesian product_ of multiple
|
||||
* [`setintersection`](/opentf/language/functions/setintersection) computes the _intersection_ of multiple sets
|
||||
* [`setproduct`](/opentf/language/functions/setproduct) computes the _Cartesian product_ of multiple
|
||||
sets.
|
||||
* [`setunion`](/terraform/language/functions/setunion) computes the _union_ of
|
||||
* [`setunion`](/opentf/language/functions/setunion) computes the _union_ of
|
||||
multiple sets.
|
||||
|
@ -33,10 +33,10 @@ the ordering of the given elements is not preserved.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`contains`](/terraform/language/functions/contains) tests whether a given list or set contains
|
||||
* [`contains`](/opentf/language/functions/contains) tests whether a given list or set contains
|
||||
a given element value.
|
||||
* [`setintersection`](/terraform/language/functions/setintersection) computes the _intersection_ of
|
||||
* [`setintersection`](/opentf/language/functions/setintersection) computes the _intersection_ of
|
||||
multiple sets.
|
||||
* [`setproduct`](/terraform/language/functions/setproduct) computes the _Cartesian product_ of multiple
|
||||
* [`setproduct`](/opentf/language/functions/setproduct) computes the _Cartesian product_ of multiple
|
||||
sets.
|
||||
* [`setsubtract`](/terraform/language/functions/setsubtract) computes the _relative complement_ of two sets
|
||||
* [`setsubtract`](/opentf/language/functions/setsubtract) computes the _relative complement_ of two sets
|
||||
|
@ -27,5 +27,5 @@ relevant literature to understand the security implications.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`filesha1`](/terraform/language/functions/filesha1) calculates the same hash from
|
||||
* [`filesha1`](/opentf/language/functions/filesha1) calculates the same hash from
|
||||
the contents of a file rather than from a string value.
|
||||
|
@ -25,7 +25,7 @@ b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`filesha256`](/terraform/language/functions/filesha256) calculates the same hash from
|
||||
* [`filesha256`](/opentf/language/functions/filesha256) calculates the same hash from
|
||||
the contents of a file rather than from a string value.
|
||||
* [`base64sha256`](/terraform/language/functions/base64sha256) calculates the same hash but returns
|
||||
* [`base64sha256`](/opentf/language/functions/base64sha256) calculates the same hash but returns
|
||||
the result in a more-compact Base64 encoding.
|
||||
|
@ -23,7 +23,7 @@ then encoded to lowercase hexadecimal digits before returning.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`filesha512`](/terraform/language/functions/filesha512) calculates the same hash from
|
||||
* [`filesha512`](/opentf/language/functions/filesha512) calculates the same hash from
|
||||
the contents of a file rather than from a string value.
|
||||
* [`base64sha512`](/terraform/language/functions/base64sha512) calculates the same hash but returns
|
||||
* [`base64sha512`](/opentf/language/functions/base64sha512) calculates the same hash but returns
|
||||
the result in a more-compact Base64 encoding.
|
||||
|
@ -27,5 +27,5 @@ list.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`substr`](/terraform/language/functions/substr) performs a similar function for characters in a
|
||||
* [`substr`](/opentf/language/functions/substr) performs a similar function for characters in a
|
||||
string, although it uses a length instead of an end index.
|
||||
|
@ -35,5 +35,5 @@ split(separator, string)
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`join`](/terraform/language/functions/join) performs the opposite operation: producing a string
|
||||
* [`join`](/opentf/language/functions/join) performs the opposite operation: producing a string
|
||||
joining together a list of strings with a given separator.
|
||||
|
@ -24,4 +24,4 @@ false
|
||||
|
||||
## Related Functions
|
||||
|
||||
- [`endswith`](/terraform/language/functions/endswith) takes two values: a string to check and a suffix string. The function returns true if the first string ends with that exact suffix.
|
||||
- [`endswith`](/opentf/language/functions/endswith) takes two values: a string to check and a suffix string. The function returns true if the first string ends with that exact suffix.
|
||||
|
@ -23,4 +23,4 @@ olleh
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`reverse`](/terraform/language/functions/reverse) reverses a sequence.
|
||||
* [`reverse`](/opentf/language/functions/reverse) reverses a sequence.
|
||||
|
@ -15,30 +15,30 @@ templatefile(path, vars)
|
||||
```
|
||||
|
||||
The template syntax is the same as for
|
||||
[string templates](/terraform/language/expressions/strings#string-templates)
|
||||
in the main Terraform language, including interpolation sequences delimited with
|
||||
[string templates](/opentf/language/expressions/strings#string-templates)
|
||||
in the main OpenTF language, including interpolation sequences delimited with
|
||||
`${` ... `}`. This function just allows longer template sequences to be factored
|
||||
out into a separate file for readability.
|
||||
|
||||
The "vars" argument must be an object. Within the template file, each of the
|
||||
keys in the map is available as a variable for interpolation. The template may
|
||||
also use any other function available in the Terraform language, except that
|
||||
also use any other function available in the OpenTF language, except that
|
||||
recursive calls to `templatefile` are not permitted. Variable names must
|
||||
each start with a letter, followed by zero or more letters, digits, or
|
||||
underscores.
|
||||
|
||||
Strings in the Terraform language are sequences of Unicode characters, so
|
||||
Strings in the OpenTF language are sequences of Unicode characters, so
|
||||
this function will interpret the file contents as UTF-8 encoded text and
|
||||
return the resulting Unicode characters. If the file contains invalid UTF-8
|
||||
sequences then this function will produce an error.
|
||||
|
||||
This function can be used only with files that already exist on disk at the
|
||||
beginning of a Terraform run. Functions do not participate in the dependency
|
||||
beginning of an OpenTF run. Functions do not participate in the dependency
|
||||
graph, so this function cannot be used with files that are generated
|
||||
dynamically during a Terraform operation.
|
||||
dynamically during an OpenTF operation.
|
||||
|
||||
`*.tftpl` is the recommended naming pattern to use for your template files.
|
||||
Terraform will not prevent you from using other names, but following this
|
||||
OpenTF will not prevent you from using other names, but following this
|
||||
convention will help your editor understand the content and likely provide
|
||||
better editing experience as a result.
|
||||
|
||||
@ -99,9 +99,9 @@ YAML that will be interpreted correctly when using lots of individual
|
||||
interpolation sequences and directives.
|
||||
|
||||
Instead, you can write a template that consists only of a single interpolated
|
||||
call to either [`jsonencode`](/terraform/language/functions/jsonencode) or
|
||||
[`yamlencode`](/terraform/language/functions/yamlencode), specifying the value to encode using
|
||||
[normal Terraform expression syntax](/terraform/language/expressions)
|
||||
call to either [`jsonencode`](/opentf/language/functions/jsonencode) or
|
||||
[`yamlencode`](/opentf/language/functions/yamlencode), specifying the value to encode using
|
||||
[normal OpenTF expression syntax](/opentf/language/expressions)
|
||||
as in the following examples:
|
||||
|
||||
```
|
||||
@ -121,9 +121,9 @@ this will produce a valid JSON or YAML representation of the given data
|
||||
structure, without the need to manually handle escaping or delimiters.
|
||||
In the latest examples above, the repetition based on elements of `ip_addrs` is
|
||||
achieved by using a
|
||||
[`for` expression](/terraform/language/expressions/for)
|
||||
[`for` expression](/opentf/language/expressions/for)
|
||||
rather than by using
|
||||
[template directives](/terraform/language/expressions/strings#directives).
|
||||
[template directives](/opentf/language/expressions/strings#directives).
|
||||
|
||||
```json
|
||||
{"backends":["10.0.0.1:8080","10.0.0.2:8080"]}
|
||||
@ -142,9 +142,9 @@ locals {
|
||||
```
|
||||
|
||||
For more information, see the main documentation for
|
||||
[`jsonencode`](/terraform/language/functions/jsonencode) and [`yamlencode`](/terraform/language/functions/yamlencode).
|
||||
[`jsonencode`](/opentf/language/functions/jsonencode) and [`yamlencode`](/opentf/language/functions/yamlencode).
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`file`](/terraform/language/functions/file) reads a file from disk and returns its literal contents
|
||||
* [`file`](/opentf/language/functions/file) reads a file from disk and returns its literal contents
|
||||
without any template interpretation.
|
||||
|
@ -10,22 +10,20 @@ description: >-
|
||||
|
||||
# `textdecodebase64` Function
|
||||
|
||||
-> **Note:** This function is supported only in Terraform v0.14 and later.
|
||||
|
||||
`textdecodebase64` function decodes a string that was previously Base64-encoded,
|
||||
and then interprets the result as characters in a specified character encoding.
|
||||
|
||||
Terraform uses the "standard" Base64 alphabet as defined in
|
||||
OpenTF uses the "standard" Base64 alphabet as defined in
|
||||
[RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
|
||||
|
||||
The `encoding_name` argument must contain one of the encoding names or aliases
|
||||
recorded in
|
||||
[the IANA character encoding registry](https://www.iana.org/assignments/character-sets/character-sets.xhtml).
|
||||
Terraform supports only a subset of the registered encodings, and the encoding
|
||||
support may vary between Terraform versions.
|
||||
OpenTF supports only a subset of the registered encodings, and the encoding
|
||||
support may vary between OpenTF versions.
|
||||
|
||||
Terraform accepts the encoding name `UTF-8`, which will produce the same result
|
||||
as [`base64decode`](/terraform/language/functions/base64decode).
|
||||
OpenTF accepts the encoding name `UTF-8`, which will produce the same result
|
||||
as [`base64decode`](/opentf/language/functions/base64decode).
|
||||
|
||||
## Examples
|
||||
|
||||
@ -36,7 +34,7 @@ Hello World
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`textencodebase64`](/terraform/language/functions/textencodebase64) performs the opposite operation,
|
||||
* [`textencodebase64`](/opentf/language/functions/textencodebase64) performs the opposite operation,
|
||||
applying target encoding and then Base64 to a string.
|
||||
* [`base64decode`](/terraform/language/functions/base64decode) is effectively a shorthand for
|
||||
* [`base64decode`](/opentf/language/functions/base64decode) is effectively a shorthand for
|
||||
`textdecodebase64` where the character encoding is fixed as `UTF-8`.
|
||||
|
@ -9,29 +9,27 @@ description: >-
|
||||
|
||||
# `textencodebase64` Function
|
||||
|
||||
-> **Note:** This function is supported only in Terraform v0.14 and later.
|
||||
|
||||
`textencodebase64` encodes the unicode characters in a given string using a
|
||||
specified character encoding, returning the result base64 encoded because
|
||||
Terraform language strings are always sequences of unicode characters.
|
||||
OpenTF language strings are always sequences of unicode characters.
|
||||
|
||||
```hcl
|
||||
substr(string, encoding_name)
|
||||
```
|
||||
|
||||
Terraform uses the "standard" Base64 alphabet as defined in
|
||||
OpenTF uses the "standard" Base64 alphabet as defined in
|
||||
[RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
|
||||
|
||||
The `encoding_name` argument must contain one of the encoding names or aliases
|
||||
recorded in
|
||||
[the IANA character encoding registry](https://www.iana.org/assignments/character-sets/character-sets.xhtml).
|
||||
Terraform supports only a subset of the registered encodings, and the encoding
|
||||
support may vary between Terraform versions. In particular Terraform supports
|
||||
OpenTF supports only a subset of the registered encodings, and the encoding
|
||||
support may vary between OpenTF versions. In particular OpenTF supports
|
||||
`UTF-16LE`, which is the native character encoding for the Windows API and
|
||||
therefore sometimes expected by Windows-originated software such as PowerShell.
|
||||
|
||||
Terraform also accepts the encoding name `UTF-8`, which will produce the same
|
||||
result as [`base64encode`](/terraform/language/functions/base64encode).
|
||||
OpenTF also accepts the encoding name `UTF-8`, which will produce the same
|
||||
result as [`base64encode`](/opentf/language/functions/base64encode).
|
||||
|
||||
## Examples
|
||||
|
||||
@ -42,10 +40,10 @@ SABlAGwAbABvACAAVwBvAHIAbABkAA==
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`textdecodebase64`](/terraform/language/functions/textdecodebase64) performs the opposite operation,
|
||||
* [`textdecodebase64`](/opentf/language/functions/textdecodebase64) performs the opposite operation,
|
||||
decoding Base64 data and interpreting it as a particular character encoding.
|
||||
* [`base64encode`](/terraform/language/functions/base64encode) applies Base64 encoding of the UTF-8
|
||||
* [`base64encode`](/opentf/language/functions/base64encode) applies Base64 encoding of the UTF-8
|
||||
encoding of a string.
|
||||
* [`filebase64`](/terraform/language/functions/filebase64) reads a file from the local filesystem
|
||||
* [`filebase64`](/opentf/language/functions/filebase64) reads a file from the local filesystem
|
||||
and returns its raw bytes with Base64 encoding, without creating an
|
||||
intermediate Unicode string.
|
||||
|
@ -13,7 +13,7 @@ description: |-
|
||||
timeadd(timestamp, duration)
|
||||
```
|
||||
|
||||
In the Terraform language, timestamps are conventionally represented as
|
||||
In the OpenTF language, timestamps are conventionally represented as
|
||||
strings using [RFC 3339](https://tools.ietf.org/html/rfc3339)
|
||||
"Date and Time format" syntax. `timeadd` requires the `timestamp` argument
|
||||
to be a string conforming to this syntax.
|
||||
@ -35,4 +35,4 @@ of adding the given direction to the given timestamp.
|
||||
|
||||
# Related Functions
|
||||
|
||||
* [`timecmp`](/terraform/language/functions/timecmp) determines an ordering for two timestamps.
|
||||
* [`timecmp`](/opentf/language/functions/timecmp) determines an ordering for two timestamps.
|
||||
|
@ -25,7 +25,7 @@ given in each timestamp. For example, `06:00:00+0200` and `04:00:00Z` are
|
||||
the same instant after taking into account the `+0200` offset on the first
|
||||
timestamp.
|
||||
|
||||
In the Terraform language, timestamps are conventionally represented as
|
||||
In the OpenTF language, timestamps are conventionally represented as
|
||||
strings using [RFC 3339](https://tools.ietf.org/html/rfc3339)
|
||||
"Date and Time format" syntax. `timecmp` requires the its two arguments to
|
||||
both be strings conforming to this syntax.
|
||||
@ -44,7 +44,7 @@ both be strings conforming to this syntax.
|
||||
```
|
||||
|
||||
`timecmp` can be particularly useful in defining
|
||||
[custom condition checks](/terraform/language/expressions/custom-conditions) that
|
||||
[custom condition checks](/opentf/language/expressions/custom-conditions) that
|
||||
involve a specified timestamp being within a particular range. For example,
|
||||
the following resource postcondition would raise an error if a TLS certificate
|
||||
(or other expiring object) expires sooner than 30 days from the time of
|
||||
@ -61,6 +61,6 @@ the "apply" step:
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`timestamp`](/terraform/language/functions/timestamp) returns the current timestamp when it is evaluated
|
||||
* [`timestamp`](/opentf/language/functions/timestamp) returns the current timestamp when it is evaluated
|
||||
during the apply step.
|
||||
* [`timeadd`](/terraform/language/functions/timeadd) can perform arithmetic on timestamps by adding or removing a specified duration.
|
||||
* [`timeadd`](/opentf/language/functions/timeadd) can perform arithmetic on timestamps by adding or removing a specified duration.
|
||||
|
@ -9,21 +9,21 @@ description: |-
|
||||
|
||||
`timestamp` returns a UTC timestamp string in [RFC 3339](https://tools.ietf.org/html/rfc3339) format.
|
||||
|
||||
In the Terraform language, timestamps are conventionally represented as
|
||||
In the OpenTF language, timestamps are conventionally represented as
|
||||
strings using [RFC 3339](https://tools.ietf.org/html/rfc3339)
|
||||
"Date and Time format" syntax, and so `timestamp` returns a string
|
||||
in this format.
|
||||
|
||||
The result of this function will change every second, so using this function
|
||||
directly with resource attributes will cause a diff to be detected on every
|
||||
Terraform run. We do not recommend using this function in resource attributes,
|
||||
OpenTF run. We do not recommend using this function in resource attributes,
|
||||
but in rare cases it can be used in conjunction with
|
||||
[the `ignore_changes` lifecycle meta-argument](/terraform/language/meta-arguments/lifecycle#ignore_changes)
|
||||
[the `ignore_changes` lifecycle meta-argument](/opentf/language/meta-arguments/lifecycle#ignore_changes)
|
||||
to take the timestamp only on initial creation of the resource. For more stable
|
||||
time handling, see the [Time Provider](https://registry.terraform.io/providers/hashicorp/time).
|
||||
|
||||
Due to the constantly changing return value, the result of this function cannot
|
||||
be predicted during Terraform's planning phase, and so the timestamp will be
|
||||
be predicted during OpenTF's planning phase, and so the timestamp will be
|
||||
taken only once the plan is being applied.
|
||||
|
||||
## Examples
|
||||
@ -35,7 +35,7 @@ taken only once the plan is being applied.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`formatdate`](/terraform/language/functions/formatdate) can convert the resulting timestamp to
|
||||
* [`formatdate`](/opentf/language/functions/formatdate) can convert the resulting timestamp to
|
||||
other date and time formats.
|
||||
* [`plantimestamp`](/terraform/language/functions/plantimestamp) will return a consistent timestamp
|
||||
* [`plantimestamp`](/opentf/language/functions/plantimestamp) will return a consistent timestamp
|
||||
representing the date and time during the plan.
|
||||
|
@ -20,5 +20,5 @@ This function uses Unicode's definition of letters and of upper- and lowercase.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`upper`](/terraform/language/functions/upper) converts _all_ letters in a string to uppercase.
|
||||
* [`lower`](/terraform/language/functions/lower) converts all letters in a string to lowercase.
|
||||
* [`upper`](/opentf/language/functions/upper) converts _all_ letters in a string to uppercase.
|
||||
* [`lower`](/opentf/language/functions/lower) converts all letters in a string to lowercase.
|
||||
|
@ -7,7 +7,7 @@ description: The tobool function converts a value to boolean.
|
||||
|
||||
`tobool` converts its argument to a boolean value.
|
||||
|
||||
Explicit type conversions are rarely necessary in Terraform because it will
|
||||
Explicit type conversions are rarely necessary in OpenTF because it will
|
||||
convert types automatically where required. Use the explicit type conversion
|
||||
functions only to normalize types returned in module outputs.
|
||||
|
||||
|
@ -7,13 +7,13 @@ description: The tolist function converts a value to a list.
|
||||
|
||||
`tolist` converts its argument to a list value.
|
||||
|
||||
Explicit type conversions are rarely necessary in Terraform because it will
|
||||
Explicit type conversions are rarely necessary in OpenTF because it will
|
||||
convert types automatically where required. Use the explicit type conversion
|
||||
functions only to normalize types returned in module outputs.
|
||||
|
||||
Pass a _set_ value to `tolist` to convert it to a list. Since set elements are
|
||||
not ordered, the resulting list will have an undefined order that will be
|
||||
consistent within a particular run of Terraform.
|
||||
consistent within a particular run of OpenTF.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -26,7 +26,7 @@ consistent within a particular run of Terraform.
|
||||
]
|
||||
```
|
||||
|
||||
Since Terraform's concept of a list requires all of the elements to be of the
|
||||
Since OpenTF's concept of a list requires all of the elements to be of the
|
||||
same type, mixed-typed elements will be converted to the most general type:
|
||||
|
||||
```
|
||||
|
@ -7,7 +7,7 @@ description: The tomap function converts a value to a map.
|
||||
|
||||
`tomap` converts its argument to a map value.
|
||||
|
||||
Explicit type conversions are rarely necessary in Terraform because it will
|
||||
Explicit type conversions are rarely necessary in OpenTF because it will
|
||||
convert types automatically where required. Use the explicit type conversion
|
||||
functions only to normalize types returned in module outputs.
|
||||
|
||||
@ -21,7 +21,7 @@ functions only to normalize types returned in module outputs.
|
||||
}
|
||||
```
|
||||
|
||||
Since Terraform's concept of a map requires all of the elements to be of the
|
||||
Since OpenTF's concept of a map requires all of the elements to be of the
|
||||
same type, mixed-typed elements will be converted to the most general type:
|
||||
|
||||
```
|
||||
|
@ -7,7 +7,7 @@ description: The tonumber function converts a value to a number.
|
||||
|
||||
`tonumber` converts its argument to a number value.
|
||||
|
||||
Explicit type conversions are rarely necessary in Terraform because it will
|
||||
Explicit type conversions are rarely necessary in OpenTF because it will
|
||||
convert types automatically where required. Use the explicit type conversion
|
||||
functions only to normalize types returned in module outputs.
|
||||
|
||||
|
@ -7,7 +7,7 @@ description: The toset function converts a value to a set.
|
||||
|
||||
`toset` converts its argument to a set value.
|
||||
|
||||
Explicit type conversions are rarely necessary in Terraform because it will
|
||||
Explicit type conversions are rarely necessary in OpenTF because it will
|
||||
convert types automatically where required. Use the explicit type conversion
|
||||
functions only to normalize types returned in module outputs.
|
||||
|
||||
@ -25,7 +25,7 @@ duplicate elements and discard the ordering of the elements.
|
||||
]
|
||||
```
|
||||
|
||||
Since Terraform's concept of a set requires all of the elements to be of the
|
||||
Since OpenTF's concept of a set requires all of the elements to be of the
|
||||
same type, mixed-typed elements will be converted to the most general type:
|
||||
|
||||
```
|
||||
|
@ -7,7 +7,7 @@ description: The tostring function converts a value to a string.
|
||||
|
||||
`tostring` converts its argument to a string value.
|
||||
|
||||
Explicit type conversions are rarely necessary in Terraform because it will
|
||||
Explicit type conversions are rarely necessary in OpenTF because it will
|
||||
convert types automatically where required. Use the explicit type conversion
|
||||
functions only to normalize types returned in module outputs.
|
||||
|
||||
|
@ -34,7 +34,7 @@ and end of the string specified in the first argument.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`trimprefix`](/terraform/language/functions/trimprefix) removes a word from the start of a string.
|
||||
* [`trimsuffix`](/terraform/language/functions/trimsuffix) removes a word from the end of a string.
|
||||
* [`trimspace`](/terraform/language/functions/trimspace) removes all types of whitespace from
|
||||
* [`trimprefix`](/opentf/language/functions/trimprefix) removes a word from the start of a string.
|
||||
* [`trimsuffix`](/opentf/language/functions/trimsuffix) removes a word from the end of a string.
|
||||
* [`trimspace`](/opentf/language/functions/trimspace) removes all types of whitespace from
|
||||
both the start and the end of a string.
|
||||
|
@ -23,7 +23,7 @@ helloworld
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`trim`](/terraform/language/functions/trim) removes characters at the start and end of a string.
|
||||
* [`trimsuffix`](/terraform/language/functions/trimsuffix) removes a word from the end of a string.
|
||||
* [`trimspace`](/terraform/language/functions/trimspace) removes all types of whitespace from
|
||||
* [`trim`](/opentf/language/functions/trim) removes characters at the start and end of a string.
|
||||
* [`trimsuffix`](/opentf/language/functions/trimsuffix) removes a word from the end of a string.
|
||||
* [`trimspace`](/opentf/language/functions/trimspace) removes all types of whitespace from
|
||||
both the start and the end of a string.
|
||||
|
@ -23,5 +23,5 @@ hello
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`chomp`](/terraform/language/functions/chomp) removes just line ending characters from the _end_ of
|
||||
* [`chomp`](/opentf/language/functions/chomp) removes just line ending characters from the _end_ of
|
||||
a string.
|
||||
|
@ -18,7 +18,7 @@ hello
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`trim`](/terraform/language/functions/trim) removes characters at the start and end of a string.
|
||||
* [`trimprefix`](/terraform/language/functions/trimprefix) removes a word from the start of a string.
|
||||
* [`trimspace`](/terraform/language/functions/trimspace) removes all types of whitespace from
|
||||
* [`trim`](/opentf/language/functions/trim) removes characters at the start and end of a string.
|
||||
* [`trimprefix`](/opentf/language/functions/trimprefix) removes a word from the start of a string.
|
||||
* [`trimspace`](/opentf/language/functions/trimspace) removes all types of whitespace from
|
||||
both the start and the end of a string.
|
||||
|
@ -107,5 +107,5 @@ A local value with the name "nonexist" has not been declared.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`can`](/terraform/language/functions/can), which tries evaluating an expression and returns a
|
||||
* [`can`](/opentf/language/functions/can), which tries evaluating an expression and returns a
|
||||
boolean value indicating whether it succeeded.
|
||||
|
@ -5,15 +5,13 @@ description: 'The type function returns the type of a given value. '
|
||||
|
||||
# `type` Function
|
||||
|
||||
-> **Note:** This function is available only in Terraform 1.0 and later.
|
||||
|
||||
`type` returns the type of a given value.
|
||||
|
||||
Sometimes a Terraform configuration can result in confusing errors regarding
|
||||
inconsistent types. This function displays terraform's evaluation of a given
|
||||
Sometimes an OpenTF configuration can result in confusing errors regarding
|
||||
inconsistent types. This function displays OpenTF's evaluation of a given
|
||||
value's type, which is useful in understanding this error message.
|
||||
|
||||
This is a special function which is only available in the `terraform console`
|
||||
This is a special function which is only available in the `opentf console`
|
||||
command. It can only be used to examine the type of a given value, and should
|
||||
not be used in more complex expressions.
|
||||
|
||||
@ -59,7 +57,7 @@ expressions are tuple and tuple, respectively.
|
||||
```
|
||||
|
||||
While this error message does include some type information, it can be helpful
|
||||
to inspect the exact type that Terraform has determined for each given input.
|
||||
to inspect the exact type that OpenTF has determined for each given input.
|
||||
Examining both `var.list` and `local.default_list` using the `type` function
|
||||
provides more context for the error message:
|
||||
|
||||
|
@ -22,5 +22,5 @@ This function uses Unicode's definition of letters and of upper- and lowercase.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`lower`](/terraform/language/functions/lower) converts letters in a string to _lowercase_.
|
||||
* [`title`](/terraform/language/functions/title) converts the first letter of each word in a string to uppercase.
|
||||
* [`lower`](/opentf/language/functions/lower) converts letters in a string to _lowercase_.
|
||||
* [`title`](/opentf/language/functions/title) converts the first letter of each word in a string to uppercase.
|
||||
|
@ -26,6 +26,6 @@ UTF-8 and then percent encoding is applied separately to each UTF-8 byte.
|
||||
Hello+World%21
|
||||
> urlencode("☃")
|
||||
%E2%98%83
|
||||
> "http://example.com/search?q=${urlencode("terraform urlencode")}"
|
||||
http://example.com/search?q=terraform+urlencode
|
||||
> "http://example.com/search?q=${urlencode("opentf urlencode")}"
|
||||
http://example.com/search?q=opentf+urlencode
|
||||
```
|
||||
|
@ -16,11 +16,11 @@ This function produces a new value each time it is called, and so using it
|
||||
directly in resource arguments will result in spurious diffs. We do not
|
||||
recommend using the `uuid` function in resource configurations, but it can
|
||||
be used with care in conjunction with
|
||||
[the `ignore_changes` lifecycle meta-argument](/terraform/language/meta-arguments/lifecycle#ignore_changes).
|
||||
[the `ignore_changes` lifecycle meta-argument](/opentf/language/meta-arguments/lifecycle#ignore_changes).
|
||||
|
||||
In most cases we recommend using [the `random` provider](https://registry.terraform.io/providers/hashicorp/random/latest/docs)
|
||||
instead, since it allows the one-time generation of random values that are
|
||||
then retained in the Terraform [state](/terraform/language/state) for use by
|
||||
then retained in the OpenTF [state](/opentf/language/state) for use by
|
||||
future operations. In particular,
|
||||
[`random_id`](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) can generate results with
|
||||
equivalent randomness to the `uuid` function.
|
||||
@ -34,4 +34,4 @@ b5ee72a3-54dd-c4b8-551c-4bdc0204cedb
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`uuidv5`](/terraform/language/functions/uuidv5), which generates name-based UUIDs.
|
||||
* [`uuidv5`](/opentf/language/functions/uuidv5), which generates name-based UUIDs.
|
||||
|
@ -16,7 +16,7 @@ uuidv5(namespace, name)
|
||||
```
|
||||
|
||||
Unlike the pseudo-random UUIDs generated by
|
||||
[`uuid`](/terraform/language/functions/uuid), name-based UUIDs derive from namespace and an name,
|
||||
[`uuid`](/opentf/language/functions/uuid), name-based UUIDs derive from namespace and an name,
|
||||
producing the same UUID value every time if the namespace and name are
|
||||
unchanged.
|
||||
|
||||
@ -77,4 +77,4 @@ defined it.
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`uuid`](/terraform/language/functions/uuid), which generates pseudorandom UUIDs.
|
||||
* [`uuid`](/opentf/language/functions/uuid), which generates pseudorandom UUIDs.
|
||||
|
@ -10,7 +10,7 @@ in that map.
|
||||
|
||||
The values are returned in lexicographical order by their corresponding _keys_,
|
||||
so the values will be returned in the same order as their keys would be
|
||||
returned from [`keys`](/terraform/language/functions/keys).
|
||||
returned from [`keys`](/opentf/language/functions/keys).
|
||||
|
||||
## Examples
|
||||
|
||||
@ -25,4 +25,4 @@ returned from [`keys`](/terraform/language/functions/keys).
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`keys`](/terraform/language/functions/keys) returns a list of the _keys_ from a map.
|
||||
* [`keys`](/opentf/language/functions/keys) returns a list of the _keys_ from a map.
|
||||
|
@ -14,10 +14,10 @@ This function supports a subset of [YAML 1.2](https://yaml.org/spec/1.2/spec.htm
|
||||
as described below.
|
||||
|
||||
This function maps YAML values to
|
||||
[Terraform language values](/terraform/language/expressions/types)
|
||||
[OpenTF language values](/opentf/language/expressions/types)
|
||||
in the following way:
|
||||
|
||||
| YAML type | Terraform type |
|
||||
| YAML type | OpenTF type |
|
||||
| ------------- | ------------------------------------------------------------------ |
|
||||
| `!!str` | `string` |
|
||||
| `!!float` | `number` |
|
||||
@ -25,11 +25,11 @@ in the following way:
|
||||
| `!!bool` | `bool` |
|
||||
| `!!map` | `object(...)` with attribute types determined per this table |
|
||||
| `!!seq` | `tuple(...)` with element types determined per this table |
|
||||
| `!!null` | The Terraform language `null` value |
|
||||
| `!!null` | The OpenTF language `null` value |
|
||||
| `!!timestamp` | `string` in [RFC 3339](https://tools.ietf.org/html/rfc3339) format |
|
||||
| `!!binary` | `string` containing base64-encoded representation |
|
||||
|
||||
The Terraform language automatic type conversion rules mean that you don't
|
||||
The OpenTF language automatic type conversion rules mean that you don't
|
||||
usually need to worry about exactly what type is produced for a given value,
|
||||
and can just use the result in an intuitive way.
|
||||
|
||||
@ -38,7 +38,7 @@ types map to the same target type -- and so round-tripping through `yamldecode`
|
||||
and then `yamlencode` cannot produce an identical result.
|
||||
|
||||
YAML is a complex language and it supports a number of possibilities that the
|
||||
Terraform language's type system cannot represent. Therefore this YAML decoder
|
||||
OpenTF language's type system cannot represent. Therefore this YAML decoder
|
||||
supports only a subset of YAML 1.2, with restrictions including the following:
|
||||
|
||||
- Although aliases to earlier anchors are supported, cyclic data structures
|
||||
@ -93,7 +93,7 @@ Call to function "yamldecode" failed: unsupported tag "!not-supported".
|
||||
|
||||
## Related Functions
|
||||
|
||||
- [`jsondecode`](/terraform/language/functions/jsondecode) is a similar operation using JSON instead
|
||||
- [`jsondecode`](/opentf/language/functions/jsondecode) is a similar operation using JSON instead
|
||||
of YAML.
|
||||
- [`yamlencode`](/terraform/language/functions/yamlencode) performs the opposite operation, _encoding_
|
||||
- [`yamlencode`](/opentf/language/functions/yamlencode) performs the opposite operation, _encoding_
|
||||
a value as YAML.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user