terraform-plugin-framework
terraform-plugin-framework copied to clipboard
function.ObjectParameter always requires all arguments
Module version
v1.6.1
Relevant provider source code
function.ObjectParameter{
Name: "args",
Description: "Extra variables for use in format.",
AllowNullValue: true,
AttributeTypes: map[string]attr.Type{
"location": types.StringType,
"extra_tokens": types.MapType{ElemType: types.StringType},
},
},
Terraform Configuration Files
provider::namep::custom_name("test", "azurerm_resource_group", { location = "westeurope" })
Expected Behavior
extra_tokens should be null since it wasn't passed
Actual Behavior
The function call fails and forces the user to explicitly pass extra_tokens = null
Steps to Reproduce
Create a provider function Have at least one parameter be an ObjectParameter Try to call the function without explicitly passing every argument
Hey there @jason-johnson 👋🏻 , thanks for reporting this and sorry you're running into this issue.
I'm able to verify the bug, but I wanted to add that there will also likely need to be some design decisions and enhancements made here by the maintainers to fully enable this behavior.
Before functions, all object implementations had accompanying schema information available to determine which object properties are allowed to be null. Since functions don't have a similar concept to configurability, we'll likely need to expose some method of defining optional attributes for an object, i.e. an object type constraint.
Not an ideal workaround, but when https://github.com/hashicorp/terraform-plugin-framework/pull/931 is merged and released, provider developers will be able to define a DynamicParameter
, which will be dynamically typed, equivalent to the any
constraint. This would allow a provider function to accept any object type (unfortunately, also every other type), and validate manually it has the required information to run the function.