terraform-plugin-sdk
terraform-plugin-sdk copied to clipboard
Clarify SchemaDiffSuppressFunc description
Description of oldValue and newValue arguments for SchemaDiffSuppressFund is confusing when the resource is changed outside of Terraform.
For example, if I change GitLab remote branch to "main" manually, Terraform will want to change the value back to null.
default_branch = "main" -> null
The null is the old value in the state, but SchemaDiffSuppressFund oldValue argument contains the string "main".
So there are three values.
| state | .tf | remote |
|---|---|---|
| null | null | "main" |
SchemaDiffSuppressFund compares remote value with desired state. Not sure if it uses .tf state or current state.
https://www.terraform.io/docs/extend/schemas/schema-behaviors.html#diffsuppressfunc
Although it is not explicitly mentioned, the diff is between current and planned value of remote resource, and the current value in the above case with default_branch is newer than the old planned value from Terraform config.