Azure / Azure/Azure-Landing-Zones

[Bug]: Enhance error message when missing policy defaults

Open
#4,064 4 comments 0 reactions 1 assignee Claimed by @Omansh5 View on GitHub
Needs: Author Feedback :ear: Product: ALZ Provider (Terraform) Product: AMBA Product: Terraform (AVM) Topic: Policy :pencil:
Dominant language
PowerShell
Stars
96
Forks
70
Avg merge
3d 1h
Merged PRs (30d)
7

Description

### Which product(s) are you raising for?

ALZ Terraform (AVM)

### What versions of the tools are you using?

- ALZ AVM module version: 0.19.0
-

### What is the bug?

We mistakenly specified the amba defaults as module inputs, but forgot to include the library reference in the alz provider.

The plan fails and the alz provider reports a random amba default as missing (every run another random amba default is reported).

Used code (you should include this in your issue template):

```terraform
provider "alz" {
library_overwrite_enabled = true
library_references = [
{
path = "platform/alz",
ref = "2025.02.0"
},
# mistakenly left out:
# {
# path = "platform/amba",
# ref = "2025.07.0"
# },
{
custom_url = "${path.root}/lib"
}
]
}

module "avm-ptn-alz" {
source = "Azure/avm-ptn-alz/azurerm"
version = "~> 0.0"
location = "westeurope"
architecture_name = "alz"
parent_resource_id = data.azapi_client_config.current.tenant_id

subscription_placement = local.subscription_placement

policy_assignments_to_modify = local.policy_assignments_to_modify

policy_default_values = {
# ALZ
log_analytics_workspace_id = jsonencode({ value = local.log_analytics_workspace_id })
ama_change_tracking_data_collection_rule_id = jsonencode({ value = local.ama_change_tracking_data_collection_rule_id })
ama_user_assigned_managed_identity_id = jsonencode({ value = local.ama_user_assigned_managed_identity_id })
ama_user_assigned_managed_identity_name = jsonencode({ value = local.ama_user_assigned_managed_identity_name })
ama_vm_insights_data_collection_rule_id = jsonencode({ value = local.ama_vm_insights_data_collection_rule_id })

# AMBA
# amba_alz_action_group_email = jsonencode({ value = local.amba_alz_action_group_email })
amba_alz_management_subscription_id = jsonencode({ value = "${var.management_subscription_id}" })
amba_alz_resource_group_location = jsonencode({ value = local.amba_alz_resource_group_location })
amba_alz_resource_group_name = jsonencode({ value = local.amba_alz_resource_group_name })
amba_alz_user_assigned_managed_identity_name = jsonencode({ value = local.amba_alz_user_assigned_managed_identity_name })
amba_alz_byo_user_assigned_managed_identity_id = jsonencode({ value = local.amba_alz_byo_user_assigned_managed_identity_id })
}
}
```

### Log Output

```Text

│ Error: architectureDataSource.Read() Error applying policy assignment default `amba_alz_byo_user_assigned_managed_identity_id`

│ with module.avm-ptn-alz.data.alz_architecture.this,
│ on .terraform\modules\avm-ptn-alz\main.tf line 1, in data "alz_architecture" "this":
│ 1: data "alz_architecture" "this" {

│ Hierarchy.AddDefaultPolicyAssignmentValue: A default with name
│ `amba_alz_byo_user_assigned_managed_identity_id` does not exist

```

### Screenshot(s)

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.