Skip to main content

Initializers


Static Functions


abs

abs returns the absolute value of the given number. In other words, if the number is zero or positive then it is returned as-is, but if it is negative then it is multiplied by -1 to make it positive before returning it.

numRequired

  • Type: typing.Union[int, float]

abspath

abspath takes a string containing a filesystem path and converts it to an absolute path. That is, if the path is not absolute, it will be joined with the current working directory.

pathRequired

  • Type: str

alltrue

alltrue returns true if all elements in a given collection are true or "true". It also returns true if the collection is empty.

listRequired

  • Type: typing.List[typing.Any]

anytrue

anytrue returns true if any element in a given collection is true or "true". It also returns false if the collection is empty.

listRequired

  • Type: typing.List[typing.Any]

base64decode

base64decode takes a string containing a Base64 character sequence and returns the original string.

strRequired

  • Type: str

base64encode

base64encode applies Base64 encoding to a string.

strRequired

  • Type: str

base64gunzip

base64gunzip decodes a Base64-encoded string and uncompresses the result with gzip.

strRequired

  • Type: str

base64gzip

base64gzip compresses a string with gzip and then encodes the result in Base64 encoding.

strRequired

  • Type: str

base64sha256

base64sha256 computes the SHA256 hash of a given string and encodes it with Base64. This is not equivalent to base64encode(sha256("test")) since sha256() returns hexadecimal representation.

strRequired

  • Type: str

base64sha512

base64sha512 computes the SHA512 hash of a given string and encodes it with Base64. This is not equivalent to base64encode(sha512("test")) since sha512() returns hexadecimal representation.

strRequired

  • Type: str

basename

basename takes a string containing a filesystem path and removes all except the last portion from it.

pathRequired

  • Type: str

can

can evaluates the given expression and returns a boolean value indicating whether the expression produced a result without any errors.

expressionRequired

  • Type: typing.Any

ceil

ceil returns the closest whole number that is greater than or equal to the given value, which may be a fraction.

numRequired

  • Type: typing.Union[int, float]

chomp

chomp removes newline characters at the end of a string.

strRequired

  • Type: str

chunklist

chunklist splits a single list into fixed-size chunks, returning a list of lists.

listRequired

  • Type: typing.List[typing.Any]

sizeRequired

  • Type: typing.Union[int, float]

cidrcontains

cidrcontains determines whether a given IP address or an address prefix given in CIDR notation is within a given IP network address prefix.

containing_prefixRequired

  • Type: str

contained_ip_or_prefixRequired

  • Type: str

cidrhost

cidrhost calculates a full host IP address for a given host number within a given IP network address prefix.

prefixRequired

  • Type: str

hostnumRequired

  • Type: typing.Union[int, float]

cidrnetmask

cidrnetmask converts an IPv4 address prefix given in CIDR notation into a subnet mask address.

prefixRequired

  • Type: str

cidrsubnet

cidrsubnet calculates a subnet address within given IP network address prefix.

prefixRequired

  • Type: str

newbitsRequired

  • Type: typing.Union[int, float]

netnumRequired

  • Type: typing.Union[int, float]

cidrsubnets

cidrsubnets calculates a sequence of consecutive IP address ranges within a particular CIDR prefix.

prefixRequired

  • Type: str

newbitsRequired

  • Type: typing.List[typing.Union[int, float]]

coalesce

coalesce takes any number of arguments and returns the first one that isn’t null or an empty string.

valsRequired

  • Type: typing.List[typing.Any]

coalescelist

coalescelist takes any number of list arguments and returns the first one that isn’t empty.

valsRequired

  • Type: typing.List[typing.Any]

compact

compact takes a list of strings and returns a new list with any empty string elements removed.

listRequired

  • Type: typing.List[str]

concat

concat takes two or more lists and combines them into a single list.

seqsRequired

  • Type: typing.List[typing.Any]

contains

contains determines whether a given list or set contains a given single value as one of its elements.

listRequired

  • Type: typing.Any

valueRequired

  • Type: typing.Any

convert

convert converts a value to the given type constraint.

valueRequired

  • Type: typing.Any

typeRequired

  • Type: typing.Any

csvdecode

csvdecode decodes a string containing CSV-formatted data and produces a list of maps representing that data.

strRequired

  • Type: str

dirname

dirname takes a string containing a filesystem path and removes the last portion from it.

pathRequired

  • Type: str

distinct

distinct takes a list and returns a new list with any duplicate elements removed.

listRequired

  • Type: typing.List[typing.Any]

element

element retrieves a single element from a list.

listRequired

  • Type: typing.Any

indexRequired

  • Type: typing.Union[int, float]

endswith

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.

strRequired

  • Type: str

suffixRequired

  • Type: str

ephemeralasnull

ephemeralasnull takes a value of any type and returns a similar value of the same type with any ephemeral values replaced with non-ephemeral null values and all non-ephemeral values preserved.

valueRequired

  • Type: typing.Any

file

file reads the contents of a file at the given path and returns them as a string.

pathRequired

  • Type: str

filebase64

filebase64 reads the contents of a file at the given path and returns them as a base64-encoded string.

pathRequired

  • Type: str

filebase64sha256

filebase64sha256 is a variant of base64sha256 that hashes the contents of a given file rather than a literal string.

pathRequired

  • Type: str

filebase64sha512

filebase64sha512 is a variant of base64sha512 that hashes the contents of a given file rather than a literal string.

pathRequired

  • Type: str

fileexists

fileexists determines whether a file exists at a given path.

pathRequired

  • Type: str

filemd5

filemd5 is a variant of md5 that hashes the contents of a given file rather than a literal string.

pathRequired

  • Type: str

fileset

fileset enumerates a set of regular file names given a path and pattern. The path is automatically removed from the resulting set of file names and any result still containing path separators always returns forward slash (/) as the path separator for cross-system compatibility.

pathRequired

  • Type: str

patternRequired

  • Type: str

filesha1

filesha1 is a variant of sha1 that hashes the contents of a given file rather than a literal string.

pathRequired

  • Type: str

filesha256

filesha256 is a variant of sha256 that hashes the contents of a given file rather than a literal string.

pathRequired

  • Type: str

filesha512

filesha512 is a variant of sha512 that hashes the contents of a given file rather than a literal string.

pathRequired

  • Type: str

flatten

flatten takes a list and replaces any elements that are lists with a flattened sequence of the list contents.

listRequired

  • Type: typing.Any

floor

floor returns the closest whole number that is less than or equal to the given value, which may be a fraction.

numRequired

  • Type: typing.Union[int, float]

format

The format function produces a string by formatting a number of other values according to a specification string. It is similar to the printf function in C, and other similar functions in other programming languages.

formatRequired

  • Type: str

argsRequired

  • Type: typing.List[typing.Any]

formatdate

formatdate converts a timestamp into a different time format.

formatRequired

  • Type: str

timeRequired

  • Type: str

formatlist

formatlist produces a list of strings by formatting a number of other values according to a specification string.

formatRequired

  • Type: str

argsRequired

  • Type: typing.List[typing.Any]

indent

indent adds a given number of spaces to the beginnings of all but the first line in a given multi-line string.

spacesRequired

  • Type: typing.Union[int, float]

strRequired

  • Type: str

index

index finds the element index for a given value in a list.

listRequired

  • Type: typing.Any

valueRequired

  • Type: typing.Any

issensitive

issensitive takes a value and returns a boolean indicating if the value is sensitive.

valueRequired

  • Type: typing.Any

jsondecode

jsondecode interprets a given string as JSON, returning a representation of the result of decoding that string.

strRequired

  • Type: str

jsonencode

jsonencode encodes a given value to a string using JSON syntax.

valRequired

  • Type: typing.Any

keys

keys takes a map and returns a list containing the keys from that map.

input_mapRequired

  • Type: typing.Any

length_of

length determines the length of a given list, map, or string.

valueRequired

  • Type: typing.Any

log

log returns the logarithm of a given number in a given base.

numRequired

  • Type: typing.Union[int, float]

baseRequired

  • Type: typing.Union[int, float]

lower

lower converts all cased letters in the given string to lowercase.

strRequired

  • Type: str

matchkeys

matchkeys constructs a new list by taking a subset of elements from one list whose indexes match the corresponding indexes of values in another list.

valuesRequired

  • Type: typing.List[typing.Any]

keysRequired

  • Type: typing.List[typing.Any]

searchsetRequired

  • Type: typing.List[typing.Any]

max

max takes one or more numbers and returns the greatest number from the set.

numbersRequired

  • Type: typing.List[typing.Union[int, float]]

md5

md5 computes the MD5 hash of a given string and encodes it with hexadecimal digits.

strRequired

  • Type: str

merge

merge takes an arbitrary number of maps or objects, and returns a single map or object that contains a merged set of elements from all arguments.

mapsRequired

  • Type: typing.List[typing.Any]

min

min takes one or more numbers and returns the smallest number from the set.

numbersRequired

  • Type: typing.List[typing.Union[int, float]]

nonsensitive

nonsensitive takes a sensitive value and returns a copy of that value with the sensitive marking removed, thereby exposing the sensitive value.

valueRequired

  • Type: typing.Any

one

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 an error.

listRequired

  • Type: typing.Any

parseint

parseint parses the given string as a representation of an integer in the specified base and returns the resulting number. The base must be between 2 and 62 inclusive.

numberRequired

  • Type: typing.Any

baseRequired

  • Type: typing.Union[int, float]

pathexpand

pathexpand takes a filesystem path that might begin with a ~ segment, and if so it replaces that segment with the current user’s home directory path.

pathRequired

  • Type: str

plantimestamp

plantimestamp returns a UTC timestamp string in RFC 3339 format, fixed to a constant time representing the time of the plan.

pow

pow calculates an exponent, by raising its first argument to the power of the second argument.

numRequired

  • Type: typing.Union[int, float]

powerRequired

  • Type: typing.Union[int, float]

regex

regex applies a regular expression to a string and returns the matching substrings.

patternRequired

  • Type: str

strRequired

  • Type: str

regexall

regexall applies a regular expression to a string and returns a list of all matches.

patternRequired

  • Type: str

strRequired

  • Type: str

replace

replace searches a given string for another given substring, and replaces each occurrence with a given replacement string.

strRequired

  • Type: str

substrRequired

  • Type: str

replaceRequired

  • Type: str

reverse

reverse takes a sequence and produces a new sequence of the same length with all of the same elements as the given sequence but in reverse order.

listRequired

  • Type: typing.Any

rsadecrypt

rsadecrypt decrypts an RSA-encrypted ciphertext, returning the corresponding cleartext.

ciphertextRequired

  • Type: str

privatekeyRequired

  • Type: str

sensitive

sensitive takes any value and returns a copy of it marked so that Terraform will treat it as sensitive, with the same meaning and behavior as for sensitive input variables.

valueRequired

  • Type: typing.Any

setintersection

The setintersection function takes multiple sets and produces a single set containing only the elements that all of the given sets have in common. In other words, it computes the intersection of the sets.

first_setRequired

  • Type: typing.List[typing.Any]

other_setsRequired

  • Type: typing.List[typing.List[typing.Any]]

setproduct

The setproduct function finds all of the possible combinations of elements from all of the given sets by computing the Cartesian product.

setsRequired

  • Type: typing.List[typing.Any]

setsubtract

The setsubtract function returns a new set containing the elements from the first set that are not present in the second set. In other words, it computes the relative complement of the second set.

aRequired

  • Type: typing.List[typing.Any]

bRequired

  • Type: typing.List[typing.Any]

setunion

The setunion function takes multiple sets and produces a single set containing the elements from all of the given sets. In other words, it computes the union of the sets.

first_setRequired

  • Type: typing.List[typing.Any]

other_setsRequired

  • Type: typing.List[typing.List[typing.Any]]

sha1

sha1 computes the SHA1 hash of a given string and encodes it with hexadecimal digits.

strRequired

  • Type: str

sha256

sha256 computes the SHA256 hash of a given string and encodes it with hexadecimal digits.

strRequired

  • Type: str

sha512

sha512 computes the SHA512 hash of a given string and encodes it with hexadecimal digits.

strRequired

  • Type: str

signum

signum determines the sign of a number, returning a number between -1 and 1 to represent the sign.

numRequired

  • Type: typing.Union[int, float]

slice

slice extracts some consecutive elements from within a list.

listRequired

  • Type: typing.Any

start_indexRequired

  • Type: typing.Union[int, float]

end_indexRequired

  • Type: typing.Union[int, float]

sort

sort takes a list of strings and returns a new list with those strings sorted lexicographically.

listRequired

  • Type: typing.List[str]

split

split produces a list by dividing a given string at all occurrences of a given separator.

separatorRequired

  • Type: str

strRequired

  • Type: str

startswith

startswith takes two values: a string to check and a prefix string. The function returns true if the string begins with that exact prefix.

strRequired

  • Type: str

prefixRequired

  • Type: str

strcontains

strcontains takes two values: a string to check and an expected substring. The function returns true if the string has the substring contained within it.

strRequired

  • Type: str

substrRequired

  • Type: str

strrev

strrev reverses the characters in a string. Note that the characters are treated as Unicode characters (in technical terms, Unicode grapheme cluster boundaries are respected).

strRequired

  • Type: str

substr

substr extracts a substring from a given string by offset and (maximum) length.

strRequired

  • Type: str

offsetRequired

  • Type: typing.Union[int, float]

lengthRequired

  • Type: typing.Union[int, float]

sum

sum takes a list or set of numbers and returns the sum of those numbers.

listRequired

  • Type: typing.Any

templatefile

templatefile reads the file at the given path and renders its content as a template using a supplied set of template variables.

pathRequired

  • Type: str

varsRequired

  • Type: typing.Any

templatestring

templatestring takes a string from elsewhere in the module and renders its content as a template using a supplied set of template variables.

templateRequired

  • Type: str

varsRequired

  • Type: typing.Any

textdecodebase64

textdecodebase64 function decodes a string that was previously Base64-encoded, and then interprets the result as characters in a specified character encoding.

sourceRequired

  • Type: str

encodingRequired

  • Type: str

textencodebase64

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.

strRequired

  • Type: str

encodingRequired

  • Type: str

timeadd

timeadd adds a duration to a timestamp, returning a new timestamp.

timestampRequired

  • Type: str

durationRequired

  • Type: str

timecmp

timecmp compares two timestamps and returns a number that represents the ordering of the instants those timestamps represent.

timestamp_aRequired

  • Type: str

timestamp_bRequired

  • Type: str

timestamp

timestamp returns a UTC timestamp string in RFC 3339 format.

title

title converts the first letter of each word in the given string to uppercase.

strRequired

  • Type: str

tobool

tobool converts its argument to a boolean value.

vRequired

  • Type: typing.Any

tolist

tolist converts its argument to a list value.

vRequired

  • Type: typing.Any

tomap

tomap converts its argument to a map value.

vRequired

  • Type: typing.Any

tonumber

tonumber converts its argument to a number value.

vRequired

  • Type: typing.Any

toset

toset converts its argument to a set value.

vRequired

  • Type: typing.Any

tostring

tostring converts its argument to a string value.

vRequired

  • Type: typing.Any

transpose

transpose takes a map of lists of strings and swaps the keys and values to produce a new map of lists of strings.

valuesRequired

  • Type: typing.Any

trim

trim removes the specified set of characters from the start and end of the given string.

strRequired

  • Type: str

cutsetRequired

  • Type: str

trimprefix

trimprefix removes the specified prefix from the start of the given string. If the string does not start with the prefix, the string is returned unchanged.

strRequired

  • Type: str

prefixRequired

  • Type: str

trimspace

trimspace removes any space characters from the start and end of the given string.

strRequired

  • Type: str

trimsuffix

trimsuffix removes the specified suffix from the end of the given string.

strRequired

  • Type: str

suffixRequired

  • Type: str

try

try evaluates all of its argument expressions in turn and returns the result of the first one that does not produce any errors.

expressionsRequired

  • Type: typing.List[typing.Any]

upper

upper converts all cased letters in the given string to uppercase.

strRequired

  • Type: str

urldecode

urldecode applies URL decoding to a given encoded string.

strRequired

  • Type: str

urlencode

urlencode applies URL encoding to a given string.

strRequired

  • Type: str

uuid

uuid generates a unique identifier string.

uuidv5

uuidv5 generates a name-based UUID, as described in RFC 4122 section 4.3, also known as a “version 5” UUID.

namespaceRequired

  • Type: str

nameRequired

  • Type: str

values

values takes a map and returns a list containing the values of the elements in that map.

mappingRequired

  • Type: typing.Any

yamldecode

yamldecode parses a string as a subset of YAML, and produces a representation of its value.

srcRequired

  • Type: str

yamlencode

yamlencode encodes a given value to a string using YAML 1.2 block syntax.

valueRequired

  • Type: typing.Any

zipmap

zipmap constructs a map from a list of keys and a corresponding list of values.

keysRequired

  • Type: typing.List[str]

valuesRequired

  • Type: typing.Any

bcrypt

bcrypt computes a hash of the given string using the Blowfish cipher, returning a string in the Modular Crypt Format usually expected in the shadow password file on many Unix systems.

strRequired

  • Type: str

costOptional

  • Type: typing.Union[int, float]

conditional

https://developer.hashicorp.com/terraform/language/expressions/conditionals A conditional expression uses the value of a boolean expression to select one of two values.

conditionRequired

  • Type: typing.Any

true_valueRequired

  • Type: typing.Any

false_valueRequired

  • Type: typing.Any

join

join produces a string by concatenating together all elements of a given list of strings with the given delimiter.

separatorRequired

  • Type: str

listRequired

  • Type: typing.List[str]

lookup

lookup retrieves the value of a single element from a map, given its key. If the given key does not exist, the given default value is returned instead.

input_mapRequired

  • Type: typing.Any

keyRequired

  • Type: str

default_valueOptional

  • Type: typing.Any

lookup_nested

returns a property access expression that accesses the property at the given path in the given inputMap. For example lookupNested(x, [“a”, “b”, “c”]) will return a Terraform expression like x[“a”][“b”][“c”]

input_mapRequired

  • Type: typing.Any

pathRequired

  • Type: typing.List[typing.Any]

range

range generates a list of numbers using a start value, a limit value, and a step value.

startRequired

  • Type: typing.Union[int, float]

limitRequired

  • Type: typing.Union[int, float]

stepOptional

  • Type: typing.Union[int, float]

raw_string

Use this function to wrap a string and escape it properly for the use in Terraform This is only needed in certain scenarios (e.g., if you have unescaped double quotes in the string).

strRequired

  • Type: str