Parameters
Parameters in function definitions describes how data values are passed to the function logic. Every parameter type has an associated value type, although this data handling is simplified for function implementations over other provider concepts, such as resource implementations.
Available Parameter Types
Function definitions support the following parameter types:
- Primitive: Parameter that accepts a single value, such as a boolean, number, or string.
- Collection: Parameter that accepts multiple values of a single element type, such as a list, map, or set.
- Object: Parameter that accepts a structure of explicit attribute names.
- Dynamic: Parameter that accepts any value type.
Primitive Parameter Types
Parameter types that accepts a single data value, such as a boolean, number, or string.
Parameter 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 Parameter Types
Parameter types that accepts multiple values of a single element type, such as a list, map, or set.
Parameter 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 Parameter Type
Parameter type that accepts a structure of explicit attribute names.
Parameter Type | Use Case |
---|---|
Object | Single structure mapping explicit attribute names |
Dynamic Parameter Type
Note
Dynamic value handling is an advanced use case. Prefer static parameter types when possible unless absolutely necessary for your use case.
Parameter that accepts any value type, determined by Terraform at runtime.
Parameter Type | Use Case |
---|---|
Dynamic | Accept any value type of data, determined at runtime. |
Parameter Naming
All parameter types have a Name
field that is required.
Missing Parameter Names
Attempting to use unnamed parameters will generate runtime errors of the following form:
Parameter Errors
Parameter names are used in runtime errors to highlight which parameter is causing the issue. For example, using a value that is incompatible with the parameter type will generate an error message such as the following:
Parameter Validation
Validation handling for provider-defined function parameters can be enabled by using custom types.
Implement the function.ValidateableParameter
interface on the custom value type to define and enable validation handling for a provider-defined function parameter, which will automatically raise an error when a value is determined to be invalid.
Refer to Custom Types for further details on creating provider-defined types and values