terraform-plugin-sdk icon indicating copy to clipboard operation
terraform-plugin-sdk copied to clipboard

Clarify SchemaDiffSuppressFunc description

Open abitrolly opened this issue 5 years ago • 2 comments

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.tfremote
nullnull"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

abitrolly avatar Jun 22 '20 12:06 abitrolly

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.

abitrolly avatar Jun 22 '20 14:06 abitrolly

CLA assistant check
All committers have signed the CLA.

hashicorp-cla avatar Mar 12 '22 18:03 hashicorp-cla