I am trying Terraform External data source to get a response.
shell script returns the result in command line. Terraform apply does not return the result. it only returns resultid = “”
data "external" "get_inst_id" {
program = ["bash", "shscripts/demo.sh"]
}
output "resultid" {
value = data.external.get_inst_id.result.id
}
sh script:
aws ec2 describe-instances --region us-west-1 > inst.json
val=$(jq -r '.Instances[] | select(.Tags[].Value | contains("demo")).InstanceId' inst.json)
jq -n --arg iid "$val" '{id: $iid}' )