How to check if a attribute in schema is computed?

Hi,
I am working on building a plugin, and I have created this attribute as TypeList and inside it I have 5 elements. Out of those 5, 3 are computed elements.
In my Update Function I want to check if the element was set as computed or not.

Is there’s anyway I can do that?
I researched a little bit and found func (*ConfigFieldReader) [ReadField]
But I am not clear how do i Get ConfigFieldReader to call ReadField function.

Any help is much appreciated.

Kind Regards,
Asis

There’s not a good way to do this from SDKv2. I’m interested in the use case, though! Given that the provider code is setting whether it’s computed or not, why can it not be coded into the CRUD functions?

1 Like

I was trying to implement typeSet behavior in typeList. I know its not a good Idea, and I have dropped it as well. So basically my use case is as below:-

I have connection_settings a typeset attribute as shown below:-
and I have a computed attribute inside this typeset

                      "connection_settings": {
                                Optional: true,
                                Computed: true,
                                Type:     schema.TypeSet,
                                Elem: &schema.Resource{
                                        Schema: map[string]*schema.Schema{
                                                "compliance_control": {
                                                        Type:     schema.TypeString,
                                                        Optional: true,
                                                        Computed: true,                                                       
                                                },
                                      },

Every time I am doing a plan, it shows (known after apply) even though in the read the old and new values are same.

Terraform Plan:-

    - connection_settings {
          - compliance_control = "CheckedMinimum" -> null
        }
      + connection_settings {
          + compliance_control = (known after apply)
	}

I want to bypass this known after apply if the values are same, but this dosnt seems to be working, but with typeList it works fine (However, with typeList I cant have mutiple blocks of connection_settings, that will cause problems if i want to delete a middle block)

PS: This provider is compatible with terraform 0.12 and I can’t use customdiff package.

Oh, so you’re trying to check whether the value shows up as “known after apply” in the plan?

Yeah, that’s not currently surfaced in SDKv2, though it’s part of other work we’re doing.