terraform-plugin-sdk
terraform-plugin-sdk copied to clipboard
GetOk() evaluates bool values of false as !exists
SDK version
2.37.0
Relevant provider source code
https://github.com/hashicorp/terraform-plugin-sdk/blob/77f585e21b398feb244cbb1890cb3d1a29ffb083/helper/schema/resource_data.go#L92-L108
Terraform Configuration Files
resource "tfe_workspace" "foobar" {
...
auto_apply = false
}
Debug Output
Expected Behavior
GetOk should return false, true meaning the value of auto_apply is false and true it exists in HCL code
Actual Behavior
because GetOk determines that the zero value of a interface-bool is false, exists = !reflect.DeepEqual(value, zero) sets exists to false and GetOk returns false,false
Workaround
Current workaround is to use GetOkExists for bool values. Which has been deprecated
Probably what should happen is if Type = bool then do not run deep check eval