Hello,
I am using the Provider Framework and have a Computed attribute which changes based on another attribute. I will call the attribute in the config A and the dependent attribute B.
The value of B is calculated when the values in A are processed. This works fine for Create, but Update gives the “produced an unexpected new value” error if a value is added to or removed from A.
To me, it seems logical, that a Computed value can change and that’s ok. I saw another post about a custom plan modifier, but the values in B must be calculated from the values in A and doing this changes the values permanently in the backing API … in this case, the value of B is not known until the apply processing completes.
Here is the schema snippet
attrs[“A”] = schema.SetAttribute{
Description: “A”,
ElementType: types.Int64Type,
Optional: true,
}
attrs["B"] = schema.MapAttribute{
Description: "B",
ElementType: types.Int64Type,
Computed: true,
PlanModifiers: []planmodifier.Map{
mapplanmodifier.UseStateForUnknown(),
},
}
What is the purpose of this? It’s storing another ID which gets created after processing A and makes it easier during Updates because all of the data is in state instead of figuring it out each time.
How can I fix this so that updated the computed value B doesn’t cause an error?
TIA