Closed zliang-akamai closed 3 months ago
Your citation says: "by the time a resource is expected to be created, read, updated, or deleted, only its computed attributes can be unknown"
That "by the time" bit is doing some heavy lifting and is probably the source of some confusion.
The error is probably happening during validation here long before we reach "the time" when attributes are guaranteed to be not unknown.
This recent documentation update is probably relevant. The upshot is that validators run early and often, so they need to be able to handle Unknown
values. Your model, because it contains a Go slice, cannot handle Unknown
values.
Changing this line to the following will probably resolve the problem, but you'll have to take extra steps when unpacking the data:
BucketAccess types.Set `tfsdk:"bucket_access"`
@chrismarget thank you so much for the answer, and you are right! I will fix the validate function in our provider accordingly.
We originally received the bug report from: https://github.com/linode/terraform-provider-linode/issues/1528
Module version
Relevant provider source code
Our schema and model design is like:
And we always use
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
to get plan values into a model.Terraform Configuration Files
In root directory:
In module directory:
Weirdly, it works fine if the resource is in the root module..
Expected Behavior
Plan doesn't contain Unknown value and conversion works well.
https://developer.hashicorp.com/terraform/plugin/framework/handling-data/terraform-concepts#unknown-values
Actual Behavior
Steps to Reproduce
terraform init
terraform apply
References
https://github.com/linode/terraform-provider-linode/issues/1528