-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't decode data in provider #99
Comments
Hi @raphink! Sorry for this confusing behavior. It looks like the In many cases Terraform is able to automatically convert values to the target type, but I think it's failing in this case because the integer value is coming from the provider code rather than from the configuration, and so the automatic type conversion behavior in the configuration language doesn't apply. With the The underlying implementation of the |
Thank you for your answer @apparentlymart. Let me see if I got that right. In order for it to work ATM, I would have to either:
Is that right? |
Hi @raphink, The
I think I am just repeating back to you what you said in more specific terms here, but I just wanted to write it out to be sure. There is a practical reason for these constraints: the state and plan formats don't currently allow dynamic type information to be retained, so This constraint may be relaxed in future, since we plan to change the state and file formats to be able to retain dynamic type information for situations like this. In the mean time, the usual way providers have achieved a dynamic "arbitrary map of anything" sort of structure is to have a string attribute called My suggestion for the immediate term would be to convert all of the values to strings -- which is what Terraform is going to do in order to write them to the state anyway -- and then users can rely on Terraform's automatic type conversions to pass numeric strings into attributes that expect integers. In the next major release we will have a It is a longer-term plan to support dynamically-typed attributes in the provider schema system, but that work is blocked by other work we are currently doing and so we've not yet planned exactly how that will work. Eventually though we do want to support an attribute whose type is decided dynamically by what is assigned to it, rather than hard-coded into the schema. At that point your I'm going to leave this labelled as a provider-sdk enhancement so we can find it again once we start that work, so we can include this use-case in the design effort. |
Merging this with #62 for richer map support. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
In camptocamp/terraform-provider-pass#6, we're hitting a situation where Terraform fails to decode a structured data to store it into a parameter.
This seems to be linked to the way https://github.com/mitchellh/mapstructure/blob/master/mapstructure.go works, but I'm not sure if it's our provider code that is wrong or if it's a bug.
The text was updated successfully, but these errors were encountered: