Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: complete starter module conditional error #71

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions templates/complete/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
archetypes: # `caf-enterprise-scale` module, add inputs as listed on the module registry where necessary.
archetypes: # `caf-enterprise-scale` module, add inputs as listed on the module registry where necessary.
root_name: es
root_id: Enterprise-Scale
deploy_corp_landing_zones: true
Expand All @@ -25,7 +25,7 @@ archetypes: # `caf-enterprise-scale` module, add inputs as listed on the module
management:
name: aa-management
connectivity:
hubnetworking: # `hubnetworking` module, add inputs as listed on the module registry where necessary.
hubnetworking: # `hubnetworking` module, add inputs as listed on the module registry where necessary.
hub_virtual_networks:
primary:
name: vnet-hub
Expand All @@ -38,7 +38,7 @@ connectivity:
sku_name: AZFW_VNet
sku_tier: Standard
subnet_address_prefix: 10.0.1.0/24
virtual_network_gateway: # `vnet-gateway` module, add inputs as listed on the module registry where necessary.
virtual_network_gateway: # `vnet-gateway` module, add inputs as listed on the module registry where necessary.
name: vgw-hub
sku: VpnGw1
type: Vpn
Expand Down
38 changes: 19 additions & 19 deletions templates/complete/locals.tf
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
locals {
config = yamldecode(file("${path.module}/config.yaml"))
archetypes = local.config.archetypes
hub_virtual_networks = {
for k, v in local.config.connectivity.hubnetworking.hub_virtual_networks : k => {
for k2, v2 in v : k2 => v2 if k2 != "virtual_network_gateway"
config = yamldecode(file("${path.module}/config.yaml"))
}
locals {
archetypes = try(merge(local.config.archetypes, {}), {})
}
locals {
hub_virtual_networks = try(merge(local.config.connectivity.hubnetworking.hub_virtual_networks, {}), {})
module_hubnetworking = {
hub_virtual_networks = {
for key, hub_virtual_network in local.hub_virtual_networks : key => {
for argument, value in hub_virtual_network : argument => value if argument != "virtual_network_gateway"
}
}
}
vritual_network_gateways = {
for k, v in local.config.connectivity.hubnetworking.hub_virtual_networks : k => merge(
v.virtual_network_gateway,
module_virtual_network_gateway = {
for key, hub_virtual_network in local.hub_virtual_networks : key => merge(
hub_virtual_network.virtual_network_gateway,
{
location = v.location
virtual_network_name = v.name
virtual_network_resource_group_name = v.resource_group_name
location = hub_virtual_network.location
virtual_network_name = hub_virtual_network.name
virtual_network_resource_group_name = hub_virtual_network.resource_group_name
}
)
}
dummy_hub_virtual_network = {
hub = {
name = "dummy"
address_space = ["0.0.0.0/0"]
location = "dummy"
resource_group_name = "dummy"
}
if can(hub_virtual_network.virtual_network_gateway)
}
}
28 changes: 14 additions & 14 deletions templates/complete/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module "enterprise-scale" {
module "enterprise_scale" {
source = "Azure/caf-enterprise-scale/azurerm"
version = "4.2.0"

disable_telemetry = true

default_location = local.archetypes.default_location
root_parent_id = try(local.archetypes.root_parent_id, data.azurerm_client_config.core.tenant_id)
count = length(local.archetypes) > 0 ? 1 : 0

disable_telemetry = try(local.archetypes.disable_telemetry, false)
default_location = try(local.archetypes.default_location, "uksouth")
root_parent_id = try(local.archetypes.root_parent_id, data.azurerm_client_config.core.tenant_id)
archetype_config_overrides = try(local.archetypes.archetype_config_overrides, {})
configure_connectivity_resources = try(local.archetypes.configure_connectivity_resources, {})
configure_identity_resources = try(local.archetypes.configure_identity_resources, {})
Expand Down Expand Up @@ -38,13 +38,12 @@ module "enterprise-scale" {
root_id = try(local.archetypes.root_id, "es")
root_name = try(local.archetypes.root_name, "Enterprise-Scale")
strict_subscription_association = try(local.archetypes.strict_subscription_association, true)
subscription_id_connectivity = var.subscription_id_connectivity
subscription_id_identity = var.subscription_id_identity
subscription_id_management = var.subscription_id_management
subscription_id_connectivity = try(local.archetypes.subscription_id_connectivity, var.subscription_id_connectivity)
subscription_id_identity = try(local.archetypes.subscription_id_identity, var.subscription_id_identity)
subscription_id_management = try(local.archetypes.subscription_id_management, var.subscription_id_management)
subscription_id_overrides = try(local.archetypes.subscription_id_overrides, {})
template_file_variables = try(local.archetypes.template_file_variables, {})


providers = {
azurerm = azurerm
azurerm.connectivity = azurerm.connectivity
Expand All @@ -54,21 +53,22 @@ module "enterprise-scale" {

module "hubnetworking" {
source = "Azure/hubnetworking/azurerm"
version = "1.1.0"
count = length(local.hub_virtual_networks) > 0 ? 1 : 0
version = "1.1.1"

count = length(local.hub_virtual_networks) > 0 ? 1 : 0

hub_virtual_networks = length(local.hub_virtual_networks) > 0 ? local.hub_virtual_networks : local.dummy_hub_virtual_network
hub_virtual_networks = local.module_hubnetworking.hub_virtual_networks

providers = {
azurerm = azurerm.connectivity
}
}

module "vnet-gateway" {
module "virtual_network_gateway" {
source = "Azure/vnet-gateway/azurerm"
version = "0.1.2"

for_each = local.vritual_network_gateways
for_each = local.module_virtual_network_gateway

location = each.value.location
name = each.value.name
Expand Down
Loading