Hi,
i have 3 environments poc, dev, prod. Each one with its own Azure Subscription.
In Terraform resource creation per each environment i have this kind of code
resource "azurerm_storage_account" "poc_storage_account" {
count = var.environment == "poc" ? 1 : 0
provider = azurerm.poc-sub
}
resource "azurerm_storage_account" "dev_storage_account" {
count = var.environment == "dev" ? 1 : 0
provider = azurerm.dev-sub
-----
}
resource "azurerm_storage_account" "prod_storage_account" {
count = var.environment == "prod" ? 1 : 0
provider = azurerm.prod-sub
______
}
locals {
storageAccountName = var.environment == "dev" ? azurerm_storage_account.dev_storage_account[0].name : azurerm_storage_account.poc_storage_account[0].name
}
My Question is is there a way to get storageAccountName variable populated based on the environment variable? Right now if you notice the above code snippet, if else condition would work if it was only 2 environments, but we have 3 environments so would like to get some help on how to get populate based on environment variable.
Thanks in advance