Data source from command output?

Hi, I am trying to find a way to fetch variables from an external command, but so far I did not succeed.
The things that comes closest seems to be local_file:

data "local_file" "foo" {
  filename = "/opt/foo.txt"

But I would like to retrieve the output of a command, and use that.
I guess such a thing would look something like:

data "local_command" "foo" {
   command = "/usr/local/bin/foo --name bar --context baz"


I think Terraform Registry would be good enough, albeit with a wrapper script to handle the JSON formatted variables.

An alternative would be to save the output of your command to a file using the local-exec provisioner inside a null_resource and read the file using the local_file data source you mentioned.

Ultimately, it will depend on whether you want to make the output available to use inside your Terraform code (in which case the JSON output would be preferable) or just pass it on to a resource as a blob.

Also note:

Terraform Enterprise does not guarantee availability of any particular language runtimes or external programs beyond standard shell utilities, so it is not recommended to use this data source within configurations that are applied within Terraform Enterprise.