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: number

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: string

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: 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: any[]

base64decode

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

strRequired

  • Type: string

base64encode

base64encode applies Base64 encoding to a string.

strRequired

  • Type: string

base64gunzip

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

strRequired

  • Type: string

base64gzip

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

strRequired

  • Type: string

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: string

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: string

basename

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

pathRequired

  • Type: string

can

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

expressionRequired

  • Type: 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: number

chomp

chomp removes newline characters at the end of a string.

strRequired

  • Type: string

chunklist

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

listRequired

  • Type: any[]

sizeRequired

  • Type: number

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: string

contained_ip_or_prefixRequired

  • Type: string

cidrhost

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

prefixRequired

  • Type: string

hostnumRequired

  • Type: number

cidrnetmask

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

prefixRequired

  • Type: string

cidrsubnet

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

prefixRequired

  • Type: string

newbitsRequired

  • Type: number

netnumRequired

  • Type: number

cidrsubnets

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

prefixRequired

  • Type: string

newbitsRequired

  • Type: number[]

coalesce

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

valsRequired

  • Type: any[]

coalescelist

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

valsRequired

  • Type: any[]

compact

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

listRequired

  • Type: string[]

concat

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

seqsRequired

  • Type: any[]

contains

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

listRequired

  • Type: any

valueRequired

  • Type: any

convert

convert converts a value to the given type constraint.

valueRequired

  • Type: any

typeRequired

  • Type: any

csvdecode

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

strRequired

  • Type: string

dirname

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

pathRequired

  • Type: string

distinct

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

listRequired

  • Type: any[]

element

element retrieves a single element from a list.

listRequired

  • Type: any

indexRequired

  • Type: number

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: string

suffixRequired

  • Type: string

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: any

file

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

pathRequired

  • Type: string

filebase64

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

pathRequired

  • Type: string

filebase64sha256

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

pathRequired

  • Type: string

filebase64sha512

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

pathRequired

  • Type: string

fileexists

fileexists determines whether a file exists at a given path.

pathRequired

  • Type: string

filemd5

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

pathRequired

  • Type: string

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: string

patternRequired

  • Type: string

filesha1

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

pathRequired

  • Type: string

filesha256

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

pathRequired

  • Type: string

filesha512

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

pathRequired

  • Type: string

flatten

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

listRequired

  • Type: 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: number

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: string

argsRequired

  • Type: any[]

formatdate

formatdate converts a timestamp into a different time format.

formatRequired

  • Type: string

timeRequired

  • Type: string

formatlist

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

formatRequired

  • Type: string

argsRequired

  • Type: 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: number

strRequired

  • Type: string

index

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

listRequired

  • Type: any

valueRequired

  • Type: any

issensitive

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

valueRequired

  • Type: any

jsondecode

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

strRequired

  • Type: string

jsonencode

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

valRequired

  • Type: any

keys

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

inputMapRequired

  • Type: any

lengthOf

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

valueRequired

  • Type: any

log

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

numRequired

  • Type: number

baseRequired

  • Type: number

lower

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

strRequired

  • Type: string

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: any[]

keysRequired

  • Type: any[]

searchsetRequired

  • Type: any[]

max

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

numbersRequired

  • Type: number[]

md5

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

strRequired

  • Type: string

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: any[]

min

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

numbersRequired

  • Type: number[]

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: 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: 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: any

baseRequired

  • Type: number

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: string

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: number

powerRequired

  • Type: number

regex

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

patternRequired

  • Type: string

strRequired

  • Type: string

regexall

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

patternRequired

  • Type: string

strRequired

  • Type: string

replace

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

strRequired

  • Type: string

substrRequired

  • Type: string

replaceRequired

  • Type: string

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: any

rsadecrypt

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

ciphertextRequired

  • Type: string

privatekeyRequired

  • Type: string

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: 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: any[]

other_setsRequired

  • Type: 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: 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: any[]

bRequired

  • Type: 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: any[]

other_setsRequired

  • Type: any[][]

sha1

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

strRequired

  • Type: string

sha256

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

strRequired

  • Type: string

sha512

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

strRequired

  • Type: string

signum

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

numRequired

  • Type: number

slice

slice extracts some consecutive elements from within a list.

listRequired

  • Type: any

start_indexRequired

  • Type: number

end_indexRequired

  • Type: number

sort

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

listRequired

  • Type: string[]

split

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

separatorRequired

  • Type: string

strRequired

  • Type: string

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: string

prefixRequired

  • Type: string

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: string

substrRequired

  • Type: string

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: string

substr

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

strRequired

  • Type: string

offsetRequired

  • Type: number

lengthRequired

  • Type: number

sum

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

listRequired

  • Type: 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: string

varsRequired

  • Type: 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: string

varsRequired

  • Type: 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: string

encodingRequired

  • Type: string

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: string

encodingRequired

  • Type: string

timeadd

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

timestampRequired

  • Type: string

durationRequired

  • Type: string

timecmp

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

timestamp_aRequired

  • Type: string

timestamp_bRequired

  • Type: string

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: string

tobool

tobool converts its argument to a boolean value.

vRequired

  • Type: any

tolist

tolist converts its argument to a list value.

vRequired

  • Type: any

tomap

tomap converts its argument to a map value.

vRequired

  • Type: any

tonumber

tonumber converts its argument to a number value.

vRequired

  • Type: any

toset

toset converts its argument to a set value.

vRequired

  • Type: any

tostring

tostring converts its argument to a string value.

vRequired

  • Type: 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: any

trim

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

strRequired

  • Type: string

cutsetRequired

  • Type: string

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: string

prefixRequired

  • Type: string

trimspace

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

strRequired

  • Type: string

trimsuffix

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

strRequired

  • Type: string

suffixRequired

  • Type: string

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: any[]

upper

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

strRequired

  • Type: string

urldecode

urldecode applies URL decoding to a given encoded string.

strRequired

  • Type: string

urlencode

urlencode applies URL encoding to a given string.

strRequired

  • Type: string

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: string

nameRequired

  • Type: string

values

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

mappingRequired

  • Type: any

yamldecode

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

srcRequired

  • Type: string

yamlencode

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

valueRequired

  • Type: any

zipmap

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

keysRequired

  • Type: string[]

valuesRequired

  • Type: 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: string

costOptional

  • Type: number

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: any

trueValueRequired

  • Type: any

falseValueRequired

  • Type: any

join

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

separatorRequired

  • Type: string

listRequired

  • Type: string[]

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.

inputMapRequired

  • Type: any

keyRequired

  • Type: string

defaultValueOptional

  • Type: any

lookupNested

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”]

inputMapRequired

  • Type: any

pathRequired

  • Type: any[]

range

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

startRequired

  • Type: number

limitRequired

  • Type: number

stepOptional

  • Type: number

rawString

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: string