Skip to content

Commit

Permalink
Add vars to azure/mysql_flexible_server and azure/mysql_flexible_serv…
Browse files Browse the repository at this point in the history
…er_public
  • Loading branch information
tom-reinders committed Aug 20, 2024
1 parent ab68b0f commit cdb8474
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/azure/mysql_flexible_server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ resource "azurerm_mysql_flexible_server_configuration" "mysql_flexible_server_co
value = var.slow_query_log
}

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

server_id = azurerm_mysql_flexible_server.mysql_flexible_server.id
identity_id = var.entra_identity_id
login = var.entra_login
object_id = var.entra_object_id
tenant_id = var.entra_tenant_id
}

data "azurerm_monitor_diagnostic_categories" "diagnostic_categories" {
count = var.log_analytics_workspace_id == null ? 0 : 1
resource_id = azurerm_mysql_flexible_server.mysql_flexible_server.id
Expand Down
30 changes: 30 additions & 0 deletions modules/azure/mysql_flexible_server/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,36 @@ variable "mysql_admin_username" {
description = "The administrator login username for the mysql server."
}

variable "entra_administrator_enabled" {
type = bool
description = "Specifies whether or not Entra authentication is enabled for this MySQL Server"
default = false
}

variable "entra_identity_id" {
type = string
description = "The Entra identity id for the mysql server."
default = null
}

variable "entra_login" {
type = string
description = "The Entra administrator login username for the mysql server."
default = null
}

variable "entra_object_id" {
type = string
description = "The Entra object id for the mysql server."
default = null
}

variable "entra_tenant_id" {
type = string
description = "The Entra tenant id for the mysql server."
default = null
}

variable "password_keeper" {
type = map(string)
description = "Random map of strings, when changed the mysql admin password will rotate."
Expand Down
19 changes: 19 additions & 0 deletions modules/azure/mysql_flexible_server_public/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ resource "azurerm_mysql_flexible_server" "mysql_flexible_server" {
size_gb = var.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]
prevent_destroy = true
Expand All @@ -66,6 +75,16 @@ resource "azurerm_mysql_flexible_server_configuration" "mysql_flexible_server_co
value = var.slow_query_log
}

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

server_id = azurerm_mysql_flexible_server.mysql_flexible_server.id
identity_id = var.entra_identity_id
login = var.entra_login
object_id = var.entra_object_id
tenant_id = var.entra_tenant_id
}

data "azurerm_monitor_diagnostic_categories" "diagnostic_categories" {
count = var.log_analytics_workspace_id == null ? 0 : 1
resource_id = azurerm_mysql_flexible_server.mysql_flexible_server.id
Expand Down
30 changes: 30 additions & 0 deletions modules/azure/mysql_flexible_server_public/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,36 @@ variable "admin_username" {
description = "The administrator login username for the mysql server."
}

variable "entra_administrator_enabled" {
type = bool
description = "Specifies whether or not Entra authentication is enabled for this MySQL Server"
default = false
}

variable "entra_identity_id" {
type = string
description = "The Entra identity id for the mysql server."
default = null
}

variable "entra_login" {
type = string
description = "The Entra administrator login username for the mysql server."
default = null
}

variable "entra_object_id" {
type = string
description = "The Entra object id for the mysql server."
default = null
}

variable "entra_tenant_id" {
type = string
description = "The Entra tenant id for the mysql server."
default = null
}

variable "password_keeper" {
type = map(string)
description = "Random map of strings, when changed the mysql admin password will rotate."
Expand Down

0 comments on commit cdb8474

Please sign in to comment.