Skip to content

Commit

Permalink
Hotfix 89 - The given value is not suitable for child module variable…
Browse files Browse the repository at this point in the history
… "archetype_config_overrides" (#93)

* Fix for #89

* Add dedicated local for prinicipal_id lookup

* Fix file formatting

* Add test coverage for #89
  • Loading branch information
Kevin Rowlandson authored May 11, 2021
1 parent 6327afa commit d900eae
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 30 deletions.
4 changes: 2 additions & 2 deletions locals.management_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ locals {
}
# Logic to determine whether to include the core Enterprise-scale
# Management Groups as part of the deployment
es_core_landing_zones_to_include = local.deploy_core_landing_zones ? local.es_core_landing_zones : local.empty_map
es_core_landing_zones_to_include = local.deploy_core_landing_zones ? local.es_core_landing_zones : null
# Logic to determine whether to include the demo "Landing Zone"
# Enterprise-scale Management Groups as part of the deployment
es_demo_landing_zones_to_include = local.deploy_demo_landing_zones ? local.es_demo_landing_zones : local.empty_map
es_demo_landing_zones_to_include = local.deploy_demo_landing_zones ? local.es_demo_landing_zones : null
# Local map containing all Management Groups to deploy
es_landing_zones_merge = merge(
local.es_core_landing_zones_to_include,
Expand Down
10 changes: 9 additions & 1 deletion locals.policy_assignments.tf
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ locals {
)
}

# Generate a list of principal_id values by Policy Assignment
locals {
principal_id_by_policy_assignment = {
for pak, pav in azurerm_policy_assignment.enterprise_scale :
pak => pav.identity[0].principal_id
}
}

# Construct the array used to determine the list of
# Role Assignments to create for the Managed Identities
# used by Policy Assignments.
Expand All @@ -224,7 +232,7 @@ locals {
{
resource_id = "${local.azurerm_policy_assignment_enterprise_scale[policy_assignment_id].scope_id}${local.provider_path.role_assignment}${uuidv5(uuidv5("url", role_definition_id), policy_assignment_id)}"
scope_id = local.azurerm_policy_assignment_enterprise_scale[policy_assignment_id].scope_id
principal_id = try(azurerm_policy_assignment.enterprise_scale[policy_assignment_id].identity[0].principal_id, null)
principal_id = try(local.principal_id_by_policy_assignment[policy_assignment_id], null)
role_definition_name = null
role_definition_id = role_definition_id
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"customer_secure": {
"policy_assignments": [
"Deny-Resource-Locations",
"Deny-RSG-Locations",
"Deploy-HITRUST-HIPAA"
],
"policy_definitions": [],
"policy_set_definitions": [],
"role_definitions": [],
"archetype_config": {
"parameters": {
"Deny-Resource-Locations": {
"listOfAllowedLocations": [
"eastus",
"eastus2",
"westus",
"northcentralus",
"southcentralus"
]
},
"Deny-RSG-Locations": {
"listOfAllowedLocations": [
"eastus",
"eastus2",
"westus",
"northcentralus",
"southcentralus"
]
}
},
"access_control": {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
"eastus2",
"westus",
"northcentralus",
"southcentralus",
"uksouth",
"ukwest"
"southcentralus"
]
},
"Deny-RSG-Locations": {
Expand All @@ -28,9 +26,7 @@
"eastus2",
"westus",
"northcentralus",
"southcentralus",
"uksouth",
"ukwest"
"southcentralus"
]
},
"Deploy-SQL-Auditing": {
Expand Down
48 changes: 46 additions & 2 deletions tests/deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,30 @@ module "test_root_id_3" {
parent_management_group_id = "${var.root_id_3}-landing-zones"
subscription_ids = []
archetype_config = {
archetype_id = "default_empty"
parameters = {}
archetype_id = "customer_secure"
parameters = {
Deny-Resource-Locations = {
listOfAllowedLocations = [
"eastus",
"westus",
]
}
Deny-RSG-Locations = {
listOfAllowedLocations = [
"eastus",
"westus",
]
}
Deploy-HITRUST-HIPAA = {
CertificateThumbprints = ""
DeployDiagnosticSettingsforNetworkSecurityGroupsrgName = "${var.root_id_3}-rg"
DeployDiagnosticSettingsforNetworkSecurityGroupsstoragePrefix = var.root_id_3
installedApplicationsOnWindowsVM = ""
listOfLocations = [
"eastus",
]
}
}
access_control = {}
}
}
Expand Down Expand Up @@ -137,6 +159,28 @@ module "test_root_id_3" {
root = {
archetype_id = "es_root"
parameters = {
Deny-Resource-Locations = {
listOfAllowedLocations = [
"eastus",
"eastus2",
"westus",
"northcentralus",
"southcentralus",
"uksouth",
"ukwest",
]
}
Deny-RSG-Locations = {
listOfAllowedLocations = [
"eastus",
"eastus2",
"westus",
"northcentralus",
"southcentralus",
"uksouth",
"ukwest",
]
}
Deploy-HITRUST-HIPAA = {
CertificateThumbprints = ""
DeployDiagnosticSettingsforNetworkSecurityGroupsrgName = "${var.root_id_3}-rg"
Expand Down
21 changes: 2 additions & 19 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,7 @@ variable "configure_management_resources" {
}

variable "archetype_config_overrides" {
type = map(
object({
archetype_id = string
parameters = any
access_control = any
})
)
type = any
description = "If specified, will set custom Archetype configurations to the default Enterprise-scale Management Groups."
default = {}
}
Expand Down Expand Up @@ -192,18 +186,7 @@ variable "subscription_id_management" {
}

variable "custom_landing_zones" {
type = map(
object({
display_name = string
parent_management_group_id = string
subscription_ids = list(string)
archetype_config = object({
archetype_id = string
parameters = any
access_control = any
})
})
)
type = any
description = "If specified, will deploy additional Management Groups alongside Enterprise-scale core Management Groups."
default = {}

Expand Down

0 comments on commit d900eae

Please sign in to comment.