Add iam_by_principals_additive to project, organization and folder modules (#2814)
* First attempt at iam_by_principals_additive * Remove validation * Update IAM ADR * Apply to organization and project modules * Update READMEs * Add tests * Remove "cycle errors"
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2024 Google LLC
|
||||
* Copyright 2025 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,19 @@ locals {
|
||||
try(local._iam_principals[role], [])
|
||||
)
|
||||
}
|
||||
iam_bindings_additive = merge(
|
||||
var.iam_bindings_additive,
|
||||
[
|
||||
for principal, roles in var.iam_by_principals_additive : {
|
||||
for role in roles :
|
||||
"iam-bpa:${principal}-${role}" => {
|
||||
member = principal
|
||||
role = role
|
||||
condition = null
|
||||
}
|
||||
}
|
||||
]...
|
||||
)
|
||||
}
|
||||
|
||||
resource "google_folder_iam_binding" "authoritative" {
|
||||
@@ -56,7 +69,7 @@ resource "google_folder_iam_binding" "bindings" {
|
||||
}
|
||||
|
||||
resource "google_folder_iam_member" "bindings" {
|
||||
for_each = var.iam_bindings_additive
|
||||
for_each = local.iam_bindings_additive
|
||||
folder = local.folder_id
|
||||
role = each.value.role
|
||||
member = each.value.member
|
||||
|
||||
Reference in New Issue
Block a user