Skip to content

Commit

Permalink
Ll integration pipeline (#30)
Browse files Browse the repository at this point in the history
* Update keyvault secrets lifecycles

* Update keyvault secrets
Fix formating

* Azure AD Role - Add msi support
  • Loading branch information
LaurentLesle authored Sep 23, 2020
1 parent f499ef9 commit fb4fad6
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 15 deletions.
9 changes: 0 additions & 9 deletions azuread.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ output aad_apps {
sensitive = true
}


module azuread_app_roles {
source = "./modules/azuread/roles"
for_each = var.azuread_app_roles

object_id = module.azuread_applications[each.key].azuread_service_principal.object_id
azuread_app_roles = each.value.roles
}

#
# Azure Active Directory Groups
#
Expand Down
16 changes: 16 additions & 0 deletions azuread_roles.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

module azuread_roles_applications {
source = "./modules/azuread/roles"
for_each = try(var.azuread_roles.azuread_apps, {})

object_id = module.azuread_applications[each.key].azuread_service_principal.object_id
azuread_roles = each.value.roles
}

module azuread_roles_msi {
source = "./modules/azuread/roles"
for_each = try(var.azuread_roles.managed_identities, {})

object_id = module.managed_identities[each.key].principal_id
azuread_roles = each.value.roles
}
5 changes: 3 additions & 2 deletions modules/azuread/applications/keyvault.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module keyvault_secret_policy {
count = try(var.settings.keyvault, null) != null ? 1 : 0
count = try(var.keyvaults[var.settings.keyvault.keyvault_key].id, null) != null ? 1 : 0
# for_each = try(var.settings.keyvault.keyvault_key, {})

source = "./keyvault"
settings = var.settings.keyvault
keyvault_id = try(var.keyvaults[var.settings.keyvault.keyvault_key].id, "")
keyvault_id = var.keyvaults[var.settings.keyvault.keyvault_key].id
password_expire_in_days = try(var.settings.password_expire_in_days, 180)

# Used by the az cli client id and ARM_CLIENT_ID
Expand Down
3 changes: 2 additions & 1 deletion modules/azuread/applications/keyvault/keyvault_secrets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ data "terraform_remote_state" "keyvaults" {
resource "azurerm_key_vault_secret" "client_id" {
name = format("%s-client-id", var.settings.secret_prefix)
value = var.application_id
key_vault_id = try(data.terraform_remote_state.keyvaults["remote_tfstate"].outputs[var.settings.remote_tfstate.output_key][var.settings.remote_tfstate.lz_key][var.settings.keyvault_key].id, var.keyvault_id)
key_vault_id = try(var.settings.remote_tfstate.tfstate_key, null) == null ? var.keyvault_id : data.terraform_remote_state.keyvaults["remote_tfstate"].outputs[var.settings.remote_tfstate.output_key][var.settings.remote_tfstate.lz_key][var.settings.keyvault_key].id
# key_vault_id = try(data.terraform_remote_state.keyvaults["remote_tfstate"].outputs[var.settings.remote_tfstate.output_key][var.settings.remote_tfstate.lz_key][var.settings.keyvault_key].id, var.keyvault_id)

lifecycle {
ignore_changes = [
Expand Down
2 changes: 1 addition & 1 deletion modules/azuread/roles/roles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resource "null_resource" "set_azure_ad_roles" {
}

for_each = {
for key in var.azuread_app_roles : key => key
for key in var.azuread_roles : key => key
}

provisioner "local-exec" {
Expand Down
2 changes: 1 addition & 1 deletion modules/azuread/roles/variables.tf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
variable object_id {}
variable azuread_app_roles {}
variable azuread_roles {}
File renamed without changes.
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ variable azuread_groups {
default = {}
}

variable azuread_app_roles {
variable azuread_roles {
default = {}
}

Expand Down

0 comments on commit fb4fad6

Please sign in to comment.