I have the below Terraform code.
I am trying to get the 'application id' of an Azure Enterpise Application.
# Get the Application_Id of the Enterprise Application having the same name as the Synapse Workspace
data "external" "enterprise_app" {
program = ["bash", "-c", <<EOT
az ad sp list --display-name "${var.enterprise_application_name}" --query "[0].appId" -o json
EOT
]
}
output "application_id" {
value = replace(data.external.enterprise_app.result, "\"", "") # remove double quotes
}
On the terraform plan I get the below error...
Error: Unexpected External Program Results │ │ with module.get_enterprise_app_application_id.data.external.enterprise_app, │ on ../../resource_modules/get_enterprise_app_application_id/main.tf line 3, in data "external" "enterprise_app": │ 3: program = ["bash", "-c", <<EOT │ 4: az ad sp list --display-name "${var.enterprise_application_name}" --query "[0].appId" -o json │
5: EOT │ 6: ] │ │ The data source received unexpected results after executing the program. │ │ Program output must be a JSON encoded map of string keys and string values. │ │ If the error is unclear, the output can be viewed by enabling Terraform's │ logging at TRACE level. Terraform documentation on logging: │ https://www.terraform.io/internals/debugging │ │ Program: /usr/bin/bash │ Result Error: json: cannot unmarshal string into Go value of type │ map[string]string
I am not sure how I can fix my code?


TRACElevel to view the actual parsedstdoutand inspect it for debugging to ensure it is the expected format.