json variable collection:
"collection1"
{
"recordset1":
{
"database_id": [
"/subscriptions/----/HemaSqlDB",
"/subscriptions/----/HemaSqlDB2",
"/subscriptions/----/HemaSqlDB3"
]
}
}
resource "azurerm_sql_failover_group" "sql_failover" {
databases = [var.database_id[0],var.database_id[1],var.database_id[2]]
}
how to achieve this dynamically ? i cannot use count_index because failover group is already existing and ì'm trying to add more databases to it.
You don't need the count, you just need to set the databases with the list variable like this:
resource "azurerm_sql_failover_group" "sql_failover" {
...
databases = var.database_id
...
}
Of course, the list must contain the existing databases and the new databases you want to add into the failover group.