Azurerm_policy_set_definition - Invalid combination of arguments

resource "azurerm_policy_set_definition" "tag_governance" {
  description         = "Contains common Tag Governance policies"
  management_group_id = data.azurerm_management_group.xx.group_id
  name                = "tag_governance"
  policy_type         = "Custom"
  display_name        = "Tag Governance"

  metadata = <<METADATA
    {
    "category": "Tags"
    }
METADATA

  dynamic "policy_definition_reference" {

    for_each = var.custom_policies_tag
    content {
      policy_definition_id = policy_definition_reference.value["policyID"]
    }
  }
}

I’m getting error:
│ “policy_definitions”: one of policy_definition_reference,policy_definitions must be specified
Although I specified policy_definition_reference

Hi @MathieuMalfeyt-TomTo,

If there were no elements in var.custom_policies_tag then this would declare zero blocks of this type, which would be one reason to see this error. Are you sure there is at least one element in that collection?

hi @ apparentlymart yes there is a list there:

module "policyset_definitions" {
  depends_on = [
    module.policy_definitions
  ]
  source = "../modules/policyset-definitions"

  custom_policies_tag = [
    {
      policyID = module.policy_definitions.xx[0]
    },
    {
      policyID = module.policy_definitions.xx[1]
    },
    {
      policyID = module.policy_definitions.xx[2]
    },
    {
      policyID = module.policy_definitions.xx[3]
    },
    {
      policyID = module.policy_definitions.xx[4]
    },
    {
      policyID = module.policy_definitions.xx[5]
    },
    {
      policyID = module.policy_definitions.xx[6]
    },
    {
      policyID = module.policy_definitions.xxy
    },
    {
      policyID = module.policy_definitions.xxz
    }
  ]
}

@apparentlymart any other things I can try for debugging purposes? Appreciate the help!