Skip to content

Commit

Permalink
Added identity property for mssql_server for IAM (#33)
Browse files Browse the repository at this point in the history
* Added identity property for mssql_server for IAM

* Added missing porperty for mssql_server

* Add identity in mssql_server output

Co-authored-by: Abdullah Khairi Kamarul Zaman <[email protected]>
  • Loading branch information
iriahk89 and Abdullah Khairi Kamarul Zaman authored Sep 25, 2020
1 parent 70eac03 commit fbc5ec6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion modules/databases/mssql_server/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@ output id {
}

output rbac_id {
value = azurerm_mssql_server.mssql.identity[0].principal_id
value = try(azurerm_mssql_server.mssql.identity[0].principal_id, null)
}

output identity {
value = try(azurerm_mssql_server.mssql.identity, null)
}

output azuread_administrator {
value = try(azurerm_mssql_server.mssql.azuread_administrator , null)
}
10 changes: 9 additions & 1 deletion modules/databases/mssql_server/server.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

resource "azurerm_mssql_server" "mssql" {

name = azurecaf_name.mssql.result
Expand All @@ -8,6 +7,7 @@ resource "azurerm_mssql_server" "mssql" {
administrator_login = var.settings.administrator_login
administrator_login_password = try(var.settings.administrator_login_password, azurerm_key_vault_secret.sql_admin_password.0.value)
public_network_access_enabled = try(var.settings.public_network_access_enabled, true)
connection_policy = try(var.settings.connection_policy, null)
tags = try(var.settings.tags, null)

dynamic "azuread_administrator" {
Expand All @@ -20,6 +20,14 @@ resource "azurerm_mssql_server" "mssql" {
}
}

dynamic "identity" {
for_each = lookup(var.settings, "identity", {}) == {} ? [] : [1]

content {
type = var.settings.identity.type
}
}

}

resource "azurecaf_name" "mssql" {
Expand Down

0 comments on commit fbc5ec6

Please sign in to comment.