My employer's Azure estate is heavily policied, which results in complications when trying to provisioning infrastructure with the AzureRM Terraform provider. For example, the Azure Key Vaults should use private link policy makes it impossible to provision Key Vaults without a private link assigned. However, creating a private link requires the target resource to already exist. This results in a catch-22 situation where both resources must be deployed simultaneously. Our current workaround is to deploy both resources at the same time via an ARM template deployment using azurerm_resource_group_template_deployment.
We are gradually trying to replace all usages of azurerm_resource_group_template_deployment with the azapi provider.
Is it possible to deploy multiple Azure resources in a single azapi_resource resource in the azapi provider?
Yes, it is possible to deploy within a single provider. you can use
depends_onblock to specify the order in which resources are created.I tried using
depends_onto create a sample workspace and container applications environment using theazapiprovider, and it worked as intended.main.tf:Initialized
terraform initand validated the configuration withterraform plan:Executed
terraform plan:Created successfully using
terraform apply:Deployed in Portal:
Reference article by @Thomas Thornton for more relevant information.
Note: In some scenarios, it would be a specific behavior of the
azapiprovider you specified if it permits installing multiple Azure resources within a singleazapi_resourceblock. In such cases, I would recommend you useAzureRMproviders to avoid any conflicts.