Saturday, March 20, 2021

IaC with Terraform for Shared Azure Resources in Multiple Subscriptions

 While you are working with multiple azure subscriptions there might be situations where you need to share infrastructure in more than one subscription. If you try to automate such situation, you can achieve that using Terraform as explained in this post.

Pre-requisites: 

  • User should have access to at least two azure subscriptions
  • Create resource group in one subscription.

Let's get started

When define the providers, create separate azurerm providers for each of the subscription. Also, you can add alias to identify the subscription easily.



Then add data block to read exiting resources in one of the Azure subscription. To get resources from another subscription, you have to clearly mention what is the provider of the existing resources you going to use in the script.


Now let's see how to use these existing resource group and deploy new resources inside that.




In this post, we have discussed how to use shared existing azure resources in multiple Azure subscriptions by adding additional provider for the data block in Terraform.

No comments:

Post a Comment