Output not showing as a field of shell_script
Closed this issue · 7 comments
So I have a resource:
resource shell_script "fa_log" {
lifecycle_commands {
create = file("${path.module}/scripts/create_custom_log.sh")
update = file("${path.module}/scripts/update_custom_log.sh")
delete = file("${path.module}/scripts/delete_custom_log.sh")
}
environment = {
LOG_GROUP_ID = fa_log_group.id
LOG_RETENTION_DAYS = var.log_retention_days
}
}
And when I later on try to collect the above fa_log output, it tells me output is not an option.
I try to do another shell_script and the last line doesn't let me access fa_log.output
resource shell_script "agent_configuration" {
lifecycle_commands {
create = file("${path.module}/scripts/create_agent_config.sh")
delete = file("${path.module}/scripts/delete_agent_config.sh")
}
environment = {
LOG_ID = jsondecode(shell_script.fa_log.output.data).resources[0].identifier
}
}
Any ideas why ?
output is a map. its not a json blob. this was done to make accessing outputs easier. it does flatten more complex json structures into that map. e.g. jsondecode(shell_script.fa_log.output["data"]).resources[0].identifier
maybe having a raw_output would be useful
Yeah, I read through the source code and saw the map. That makes sense, but the issue is before that. It does not allow me to say fa_log.output. Meaning it says it is an unresolved reference and it's red.
It's like it doesn't see the field for some reason
Based on the source code it should be there
Even when I created my own output in terraform, I still couldn't find the field inside fa_log
i think this may have to do with terraform 0.14.6 change that was released an hour ago. i will look into it
Thank you. If it is of any help I took the idea of using this from a friend and the example I posted here was working for him last time we talked. So maybe it is what you're pointing out. Please let me know if you find anything, thanks
i tested with the latest version of terraform (0.14.6) and all test cases pass. also i performed some manual tests as well which also passed. if you don't mind, could you share with me the version of Terraform you are using and the version of the provider? also if you have an example of what the json output looks like that would be helpful too
Sure, this is actually time pressing. Would you be able to email me directly at gnaomne@gmail.com ? I can set up a quick zoom so I can show you this quicker. Won't take long, thanks