Terraform
Returns
A return in a function definition describes the result data value from function logic. Every return type has an associated value type, although this data handling is simplified for function implementations over other provider concepts, such as resource implementations.
Available Return Types
Function definitions support the following return types:
- Primitive: Return that expects a single value, such as a boolean, number, or string.
- Collection: Return that expects multiple values of a single element type, such as a list, map, or set.
- Object: Return that expects a structure of explicit attribute names.
- Dynamic: Return that can be any value type.
Primitive Return Types
Return types that expect a single data value, such as a boolean, number, or string.
Return Type | Use Case |
---|---|
Bool | Boolean true or false |
Float32 | 32-bit floating point number |
Float64 | 64-bit floating point number |
Int32 | 32-bit integer number |
Int64 | 64-bit integer number |
Number | Arbitrary precision (generally over 64-bit, up to 512-bit) number |
String | Collection of UTF-8 encoded characters |
Collection Return Types
Return types that expect multiple values of a single element type, such as a list, map, or set.
Return Type | Use Case |
---|---|
List | Ordered collection of single element type |
Map | Mapping of arbitrary string keys to values of single element type |
Set | Unordered, unique collection of single element type |
Object Return Type
Return type that expects a structure of explicit attribute names.
Return Type | Use Case |
---|---|
Object | Single structure mapping explicit attribute names |
Dynamic Return Type
Return type that can be any value type, determined by the provider at runtime.
Return Type | Use Case |
---|---|
Dynamic | Return any value type of data, determined at runtime. |