11# Configure a policy assignment for a specific resource
22resource "azurerm_resource_policy_assignment" "res_assignment" {
3- count = var. resource_id != " " && local. resource_id_type == " resource" ? 1 : 0
3+ count = var. resource_id != null && local. resource_id_type == " resource" ? 1 : 0
44
55 name = var. assignment_name
66 resource_id = var. resource_id
@@ -19,7 +19,7 @@ resource "azurerm_resource_policy_assignment" "res_assignment" {
1919
2020# Configure a policy assignment for a specific resource group
2121resource "azurerm_resource_group_policy_assignment" "rg_assignment" {
22- count = var. resource_id != " " && local. resource_id_type == " resource-group" ? 1 : 0
22+ count = var. resource_id != null && local. resource_id_type == " resource-group" ? 1 : 0
2323
2424 name = var. assignment_name
2525 resource_group_id = var. resource_id
@@ -38,7 +38,7 @@ resource "azurerm_resource_group_policy_assignment" "rg_assignment" {
3838
3939# Configure a policy assignment for a specific resource group
4040resource "azurerm_subscription_policy_assignment" "sub_assignment" {
41- count = var. resource_id != " " && local. resource_id_type == " subscription" ? 1 : 0
41+ count = var. resource_id != null && local. resource_id_type == " subscription" ? 1 : 0
4242
4343 name = var. assignment_name
4444 subscription_id = var. resource_id
@@ -59,7 +59,7 @@ resource "azurerm_role_assignment" "role" {
5959 count = var. create_remediator_role ? 1 : 0
6060
6161 scope = var. policy_assignment_scope
62- principal_id = var. policy_assignment_principal_id
62+ principal_id = var. policy_assignment_principal_id != null ? var . policy_assignment_principal_id : local . principal_id
6363 role_definition_name = " Resource Policy Contributor"
6464
6565 condition = << EOT
0 commit comments