In the previous recipe, we learned the practical case of using a data block to obtain the properties of an Azure resource.
We will look in this recipe at a data source in the azurerm provider that is generic and allows you to get information about any provisioned resource in Azure.
Getting ready
In this recipe, we will write a Terraform configuration that adds security rules to several Azure Network Security Groups (NSGs) already provisioned (manually or by Terraform). Its purpose is to add these rules to all NSGs that have the tag DEFAULTRULES=TRUE.
In addition, we have already created three NSGs in the Resource Group called RG-DEMO. Among these NSGs, only NSG1 and NSG2 have the tag DEFAULTRULES=TRUE.
The source code for this recipe is available here: https://github.com/PacktPublishing/Terraform-Cookbook/tree/master/CHAP06/listresources
How to do it…
Perform the following steps in order to get Azure resources:
- In the main.tf file...