Execute Azure CLI commands when using Terraform Cloud

Hi! I am new to Terraform (and currently in “experiencing/learning mode”), but I am using terraform cloud to deploy resources in azure. However, to deploy a mysql replica, I understand that this cant be done by terraform directly, but has to be done by for example azure cli.

If I run a “local” terraform in a azure cloud shell, I can get the following code to work as expected:

resource “null_resource” “azure-cli” {

provisioner “local-exec” {

command = "az mysql server replica create --name $replicaserver --source-server $sourceserver --resource-group $rg_name --location westeurope"

However, when running the same code in terraform cloud, I get “exit status 127. Output: /bin/sh: 1: az: not found”.

Can someone point me in the right direction on how to run azure cli commands when I am using Terraform Cloud?

2 Likes