I have an Azure CLI command that returns Cognitive Search API Keys and need to use its ouput in terraform. The command reads
> az search admin-key show -g <my resource group> --service-name <my search service>
{
"primaryKey": "1...",
"secondaryKey": "4..."
}
I am using this Terraform resource:
data "external" "search_admin_key" {
count = local.deploy_indexes ? 1 : 0
program = [
"az", "search admin-key show -g ${var.rg_name} --service-name ${var.cognitive_search_name}"
]
}
and I can not get it working on windows:
- when I use just one string in the array with the entire command, I get an error
executable file not found in %PATH% - when I keep
azas first element and everything else in second, I get an errorError Message: ERROR: 'search admin-key show -g <my resource group> --service-name <my search service>' is misspelled or not recognized by the system.
Note that I use az in null-resource / local-exec provisioners and it works fine there.
How can I fix the problem and run the command I need via external data source syntax?