-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
jsondecode function #10363
Comments
And better support nested map and list. |
Hi @matti and @ckyoog! This is an old issue, but I have some news about it! The current configuration language can't support a function like this because it has no way to model a function whose return type depends on its input value. For a little while now we've been working on a revamp of the configuration language to address a number of shortcomings and limitations, and this is one of the things the new implementation can now support. We're going to be rolling this new implementation out cautiously because it's a big change that will almost definitely contain some small breaking changes that we need to manage. However, we are planning to release an opt-in preview version of it soon to gather feedback and find as many bugs as possible. This initial release should include the new |
Thank you @apparentlymart! It's really a good news! I can't wait to see what brilliant features the new implementation can bring to us. |
just found out that @ewbankkit has done this: https://github.com/EvilSuperstars/terraform-provider-jsondecode |
"The subset of JSON that can be decoded is limited - boolean, number, string, object with string values and array of strings." - see tests: https://github.com/EvilSuperstars/terraform-provider-jsondecode/blob/master/decode/data_source_decode_test.go |
I also gave a try, not as good, but might help someone https://github.com/matti/terraform-json-map |
Is |
I'm hoping that Reliable JSON syntax promised here will give us what we need. |
That's not the same as being able to process json. |
Although it's not included in the list in the article there, @robinbowes is correct that this is something separate than "Reliable JSON syntax", which is about Terraform's handling of its own configuration files written in JSON format ( |
@apparentlymart Do you have any idea when 0.12 will be released? Is it days/weeks/months away? |
There are more details on the 0.12 release in the announcement blog post. |
"later this summer" - some time before mid-Sept? :) One thing that occurred to me - will providers also be updated for 0.12? For example, I'd like to use the http provider to pull JSON from an api, but unless it's been re-written for 0.12 then it won't support the more complex JSON structures. |
The http provider JSON use-case is one I am interested in too |
The |
I just tried the following in v0.12.0-alpha1: output "foo" {
value = jsondecode(<<EOT
{
"foo": "bar",
"baz": ["boop"]
}
EOT
)
}
The Thanks for filing this feature request, and for the patience while we got through the groundwork to make a function like this possible. |
Already commented on hashicorp/terraform-provider-aws#4789 but also related here: Here's a partial solution for Terraform v0.11 without any dependencies:
Or throw it into a module and return the whole map as output:
The only limitation is, that the external data provider can apparently not deal with arrays. So only works with json maps...
|
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. |
jsonencode could be used as a way to pass lists and maps to module if there was a jsondecode function (or jsonparse etc).
The text was updated successfully, but these errors were encountered: