Skip to content

Commit

Permalink
Fix for_each statement
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-reinders committed Aug 20, 2024
1 parent cdb8474 commit 7c13823
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion modules/azure/mysql_flexible_server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ resource "azurerm_mysql_flexible_server" "mysql_flexible_server" {
size_gb = var.mysql_server_storage_max
}

dynamic "identity" {
for_each = var.entra_administrator_enabled == false ? [] : ["1"]

content {
type = "UserAssigned"
identity_ids = [var.entra_identity_id]
}
}

lifecycle {
ignore_changes = [zone]
}
Expand All @@ -69,7 +78,7 @@ resource "azurerm_mysql_flexible_server_configuration" "mysql_flexible_server_co
}

resource "azurerm_mysql_flexible_server_active_directory_administrator" "entra_admin" {
for_each = var.entra_administrator_enabled == false ? [] : [1]
for_each = var.entra_administrator_enabled == false ? [] : ["1"]

server_id = azurerm_mysql_flexible_server.mysql_flexible_server.id
identity_id = var.entra_identity_id
Expand Down
4 changes: 2 additions & 2 deletions modules/azure/mysql_flexible_server_public/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ resource "azurerm_mysql_flexible_server" "mysql_flexible_server" {
}

dynamic "identity" {
for_each = var.entra_administrator_enabled == false ? [] : [1]
for_each = var.entra_administrator_enabled == false ? [] : ["1"]

content {
type = "UserAssigned"
Expand Down Expand Up @@ -76,7 +76,7 @@ resource "azurerm_mysql_flexible_server_configuration" "mysql_flexible_server_co
}

resource "azurerm_mysql_flexible_server_active_directory_administrator" "entra_admin" {
for_each = var.entra_administrator_enabled == false ? [] : [1]
for_each = var.entra_administrator_enabled == false ? [] : ["1"]

server_id = azurerm_mysql_flexible_server.mysql_flexible_server.id
identity_id = var.entra_identity_id
Expand Down

0 comments on commit 7c13823

Please sign in to comment.