scottwinkler / terraform-provider-shell

Terraform provider for executing shell commands and saving output to state file
Mozilla Public License 2.0
281 stars 61 forks source link

Document what JSON types are permitted #131

Open pauldraper opened 9 months ago

pauldraper commented 9 months ago

I tried outputting a JSON string for create. Didn't work.

I tried outputting a JSON object. That worked.

It would be good to documentation what JSON types are permitted.

sunevnuahs commented 5 months ago

I think the detail of what can be used for output is best described in the data source docs where it states:

"The JSON can be a complex nested JSON, but will be flattened into a map[string]string. The reason for this is that your JSON payload variables can be accessed from the output map of this resource and used like a normal terraform output, so the value must be a string. You can use the built-in jsondecode() function to read nested JSON values if you really need to.".

Docs could certainly be better for this; the example referenced in the tests is:

{ "commit_id": "b8f2b8b", "environment": "$yolo", "tags_at_commit": "sometags", "project": "someproject", "current_date": "09/10/2014", "version": "someversion" }

As it states, needs to be flattened into map[string]string, so a simple json string would need to also be output as the most basic map of key/value.

{ "somestringkey": "somestringvalue" }