scottwinkler / terraform-provider-shell

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

Raw Output instead of Output #88

Open scottwinkler opened 3 years ago

scottwinkler commented 3 years ago

Instead of forcing people to output JSON, it would be nice to have the option of outputting a string. e.g. echo "hello" would return just the string "hello". No need to wrap it in a JSON data structure. If someone is using this approach, only the last line of output will be considered.

JSON is still supported, but instead of flattening it on your behalf, just let people use decodejson() which is what people were doing anyways for deeply nested JSON outputs.

In the short term will support both, and mark output as deprecated. Output can be deprecated in a 2.0 release.

LukeCarrier commented 3 years ago

Also worth noting that since the output type is map(string) the current implementation silently fails for deeply nested structures, which wouldn't be an issue with Terraform's own jsondecode(). Given this limitation I don't think there's a compelling reason to handle the decode in the resource.