Object Function Return
Object function return expects a single structure mapping explicit attribute names to type definitions from function logic. Set values in function logic with a Go structure type annotated with tfsdk
field tags or the framework map type.
Function Definition
Use the function.ObjectReturn
type in the function definition.
The AttributeTypes
field must be defined, which represents a mapping of attribute names to framework value types. An attribute type may itself contain further collection or object types, if necessary.
In this example, a function definition includes an object return:
Custom Types
You may want to build your own data value and type implementations to allow your provider to combine validation and other behaviors into a reusable bundle. This helps avoid duplication and ensures consistency. These implementations use the CustomType
field in the return type.
Refer to Custom Types for further details on creating provider-defined types and values.
Documentation
Return documentation is expected in the top-level function documentation. Refer to function documentation for information about the Summary
, Description
, and MarkdownDescription
fields available.
Setting Return Data
The function implementation documentation covers the general methods for setting function return data in function logic.
When setting the value for this return:
- If
CustomType
is set, use its associated value type. - Otherwise, use a Go structure type annotated with
tfsdk
field tags or framework map type.
In this example, a function defines a map of string return and sets its value: