-
Notifications
You must be signed in to change notification settings - Fork 101
Description
Module version
v1.7.0
Use-cases
I'm trying to add the new support of dynamic type to the restful provider (a general provider for support restful APIs), in my test branch.
There is a major resource in this provider named restful_resource
. The essential attribute is the body
, which was a string represents the configurable attribute of this restful resource. Meanwhile it exports an attribute named output
that by default holds the whole API model, which is also a string.
What I'm trying to do is to change the types of body
and output
from string to dynamic type. To support these well, the type consistency needs to take into consideration for sure. For the body
, it works well as the types of each attribute is defined by the user's TF config (though there are still works needed for import support, but I leave it as is off topic).
Whilst for output
, since it is a comptued only attribute, we don't have the information of type. So in this case, what we can do is to imply the types of a JSON object by default. E.g. assume the json array as tuple
, and json object as object
. The problem of doing this is that when something changed in the remote end (comparing to the state), e.g. size change for a tuple
, or new attribute added for an object
, we will violate the type consistency issue, results into error like below:
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to examplecloud_thing.example, provider "provider["TYPE"]" produced an unexpected new value: .example_attribute: wrong final value type: tuple required.
│
│ This is a bug in the provider, which should be reported in the providers own issue tracker.
Attempted Solutions
Proposal
I'm not sure whether it is possible or introduce a side effect, but I'd like there is a way to allow computed only attribute to tolerate the type inconsistency issue above, so that we can manage to change the type of output
to dynamic.
Meanwhile, if there is anything I missed during my implementation, it's also appreciated to point out.