Open
Description
Module version
v1.0.1
Use-cases
Providers coming from terraform-plugin-sdk may be looking for functionality similar to helper/customdiff.ComputedIf
(which itself was an actual implementation of helper/schema.Schema.ComputedWhen
). Its purpose was to set the plan value for the attribute as unknown if the given function returned true, which paired well with (schema.ResourceDiff).HasChanges()
.
In this terraform-plugin-sdk example, the version
attribute value is set to unknown, if the value
attribute is ever changed:
customdiff.ComputedIf("version", func(_ context.Context, diff *schema.ResourceDiff, _ interface{}) bool {
return diff.HasChange("value")
}),
Attempted Solutions
Providers would manually need to implement a similar attribute plan modifier or resource-level plan modification.
Proposal
To be filled in further
Potentially introduce the following in each of the typed plan modifiers:
func UnknownIf(UnknownIfFunc) planmodifier.XXX
func UnknownIfChanged(...path.Expression) planmodifier.XXX