It works fine, the output goes as json format into a file
output.json:
[
“hello”,
“hello2”,
“hello3”
]
But , how do I read it back this file back to terraform to make a “list” out of these values, I’ve used jsondecode(), but didn’t work. Is there any workaround for this?
It’s generally not recommended to try and generate files with terraform, and reference them within the configuration, because the file is not going to exist until after to apply the configuration, so reading it will fail in certain contexts.
If you want a resource which can execute arbitrary commands, there are some community providers like scottwinkler/shell that may work for your use case.
In this case however you may want to see if there is a data source from the aws provider itself which can read out the lambda functions without relying on shelling out to the the aws cli at all. If there is no such data source and the task of reading out a set of lambda functions is a common one, it may be worth submitting a feature requests to the provider team.