Below is my variables.tf
variable "storageaccounts" {
type = "map"
default = {
sa1 = {
name = "sa1test"
location = "westeurope"
account_kind = "StorageV2"
account_tier = "Standard"
account_replication_type = "LRS"
access_tier = "Hot"
resource_group_name = "bla"
}
sa2 = {
name = "sa2test"
location = "westeurope"
account_kind = "StorageV2"
account_tier = "Standard"
account_replication_type = "LRS"
access_tier = "Cool"
resource_group_name = "bla2"
}
}
}
I created the below resources
resource "azurerm_resource_group" "rg" {
for_each = "${var.storageaccounts}"
name = "${each.value.resource_group_name}"
location = "${each.value.location}"
}
resource "azurerm_storage_account" "storageaccounts" {
for_each = "${var.storageaccounts}"
name = "${each.value.name}"
resource_group_name = "${each.value.resource_group_name}"
location = "${each.value.location}"
account_replication_type = "${each.value.account_replication_type}"
account_tier = "${each.value.account_tier}"
}
How to create the resourcegroups first without the use of depends_on