Open timofurrer opened 2 years ago
Hi @timofurrer 👋 Thank you for raising this and sorry you ran into this frustrating behavior.
This SDK unfortunately implements some automatic behaviors which are difficult to workaround in provider implementations. Schema attributes that are set as Optional
+ Computed
will preserve their known prior state value if a configuration value changes to null or a zero-value of the type (e.g. ""
for strings). Changing this behavior would require a major version release since many providers are reliant on the existing behavior.
I do not believe there is a workaround for this except to potentially introduce a separate attribute that gets filled in with the infrastructure value so Computed
can be removed from the configurable attribute and disable the automatic behavior. It may also be possible to use a Default
value if there is an appropriate default infrastructure value to trigger the SDK to treat an empty string as different.
The team that maintains this SDK has been working on a reimagined development experience that does not have this automatic behavior over in the Terraform Plugin Framework. The Which SDK? page can provide some guidance on whether to adopt that SDK is appropriate and the framework documentation is now includes a Migrating from SDK section. It is targeted for a version 1.0.0 release next month.
@bflad 👋 Thanks for the answer!
It is targeted for a version 1.0.0 release next month.
What's the best way to follow that release (schedule) ?
To be notified when the release happens, you can watch the terraform-plugin-framework GitHub repository's releases, watch the Plugin Development section in HashiCorp Discuss, or subscribe to the HashiCorp blog.
As for the scheduling, you can see the remaining items drop out of the v1.0.0 milestone as they move into other milestones.
In one of my resources I have the following schema:
When changing from this config:
to this:
it won't trigger a change, because of this:
https://github.com/hashicorp/terraform-plugin-sdk/blob/ac0b9654b5217af313c746f205b98f3278e3f20b/helper/schema/schema.go#L565
What's the proper way to solve this situation?
In this case
some_attr
is optional and the "infrastructure" may set it to something (hence the computed) or the terraform user can chose to do so.