From 182c27202c90d087a405f252884fce434cbdfd3a Mon Sep 17 00:00:00 2001 From: Pedro Barbosa Date: Wed, 28 Dec 2022 17:27:55 +0100 Subject: [PATCH] fix: fix folder and project exclusions (#71) --- modules/org_policy_v2/boolean_constraints.tf | 8 ++++---- modules/org_policy_v2/list_constraints.tf | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/org_policy_v2/boolean_constraints.tf b/modules/org_policy_v2/boolean_constraints.tf index 337df1e..1f44a03 100644 --- a/modules/org_policy_v2/boolean_constraints.tf +++ b/modules/org_policy_v2/boolean_constraints.tf @@ -104,8 +104,8 @@ resource "google_org_policy_policy" "project_policy_boolean" { resource "google_org_policy_policy" "policy_boolean_exclude_folders" { for_each = (local.boolean_policy && !local.project) ? var.exclude_folders : [] - name = "${local.policy_root}/${var.policy_root_id}/policies/${var.constraint}" - parent = "${local.policy_root}/${var.policy_root_id}" + name = "folders/${each.value}/policies/${var.constraint}" + parent = "folders/${each.value}" spec { rules { @@ -119,8 +119,8 @@ resource "google_org_policy_policy" "policy_boolean_exclude_folders" { resource "google_org_policy_policy" "policy_boolean_exclude_projects" { for_each = (local.boolean_policy && !local.project) ? var.exclude_projects : [] - name = "${local.policy_root}/${var.policy_root_id}/policies/${var.constraint}" - parent = "${local.policy_root}/${var.policy_root_id}" + name = "projects/${each.value}/policies/${var.constraint}" + parent = "projects/${each.value}" spec { rules { diff --git a/modules/org_policy_v2/list_constraints.tf b/modules/org_policy_v2/list_constraints.tf index 7c93135..83910e0 100644 --- a/modules/org_policy_v2/list_constraints.tf +++ b/modules/org_policy_v2/list_constraints.tf @@ -128,8 +128,9 @@ resource "google_org_policy_policy" "project_policy" { resource "google_org_policy_policy" "folder_policy_list_exclude_folders" { for_each = (local.list_policy && !local.project) ? var.exclude_folders : [] - name = "${local.policy_root}/${var.policy_root_id}/policies/${var.constraint}" - parent = "${local.policy_root}/${var.policy_root_id}" + name = "folders/${each.value}/policies/${var.constraint}" + parent = "folders/${each.value}" + spec { reset = true @@ -142,8 +143,8 @@ resource "google_org_policy_policy" "folder_policy_list_exclude_folders" { resource "google_org_policy_policy" "project_policy_list_exclude_projects" { for_each = (local.list_policy && !local.project) ? var.exclude_projects : [] - name = "${local.policy_root}/${var.policy_root_id}/policies/${var.constraint}" - parent = "${local.policy_root}/${var.policy_root_id}" + name = "projects/${each.value}/policies/${var.constraint}" + parent = "projects/${each.value}" spec { reset = true