Is there a way to incorporate the for_each
block in a Terraform test file? I have multiple resource groups created and need to devise tests for each one.
Although I can write separate test cases for each resource, I’m wondering if there’s a way to utilize the for_each
block within the run
block or if there are any alternative suggestions to address this situation?
variable resource_group_variables = {
“resource_group_1” = {
resource_group_name = “test1”
resource_group_location = “eastus2”
resource_group_managed_by = “blabla” #(optional) The ID of the resource or application that manages this Resource Group.
resource_group_tags = {
Created_By = “testuser”,
Department = “IT”
}
},
“resource_group_2” = {
resource_group_name = “test2” #(Required) Name of the Resouce Group with which it should be created.
resource_group_location = “westus”
resource_group_managed_by = “blabla”
resource_group_tags = {
Created_By = “testuser”,
Department = “IT”
}
}
}