Skip to content

Commit

Permalink
fix: fix merge behaviour, add example
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelamattes committed Dec 16, 2021
1 parent 503534f commit 7f8834f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
33 changes: 33 additions & 0 deletions examples/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module "keyvault" {
source = "../terraform-keyvault"
location = "westeurope"
resource_name = [
"service-mgmt-kv",
]
keyvault = {
resource_group_name = "service-mgmt-rg"
tenant_id = data.azurerm_subscription.current.tenant_id
}
keyvault_config = {
mgmt = {
access_policies = {
frontdoor = {
object_id = data.azuread_service_principal.frontdoor.object_id
key_permissions = []
certificate_permissions = ["get", ]
secret_permissions = ["get", ]
}
}
}
env = {
access_policies = {
admin = {
object_id = data.azuread_group.grp-admin.object_id
}
}
}
}
tags = {
service = "service_name"
}
}
14 changes: 6 additions & 8 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
variable "resource_name" {
type = set(string)
default = {}
type = set(string)
default = []
description = "Azure Keyvault"
}
variable "location" {
Expand Down Expand Up @@ -48,12 +48,10 @@ locals {

# deep merge over merged config and use defaults if no variable is set
keyvault_config = {
# get all config
for config in keys(var.keyvault_config) :
instance => {
for config in keys(local.default.keyvault_config) :
config =>
merge(local.default.keyvault_config, local.merged.keyvault_config[instance][config])
for config in keys(local.default.keyvault_config) :
config => {
for instance in keys(var.keyvault_config[config]) :
instance => merge(local.default.keyvault_config[config], var.keyvault_config[config][instance])
}
}
}

0 comments on commit 7f8834f

Please sign in to comment.