From 9e0f39a411aa45c131051a4289c73fa7345a262c Mon Sep 17 00:00:00 2001 From: Julio Castillo Date: Tue, 5 Apr 2022 15:28:51 +0200 Subject: [PATCH 1/3] Add prefix to project factory SA bindings Co-authored-by: Antonio Lopez --- examples/factories/project-factory/main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/factories/project-factory/main.tf b/examples/factories/project-factory/main.tf index 4efdaeac0..2bbd78eb4 100644 --- a/examples/factories/project-factory/main.tf +++ b/examples/factories/project-factory/main.tf @@ -24,10 +24,11 @@ locals { } _group_iam_bindings = distinct(flatten(values(var.group_iam))) # internal structures for project service accounts IAM bindings + _project_id = coalesce(var.prefix, "") == "" ? var.project_id : "${var.prefix}-${var.project_id}" _service_accounts_iam = { for r in local._service_accounts_iam_bindings : r => [ for k, v in var.service_accounts : - "serviceAccount:${k}@${var.project_id}.iam.gserviceaccount.com" + "serviceAccount:${k}@${local._project_id}.iam.gserviceaccount.com" if try(index(v, r), null) != null ] } From 60e7da861491a10e402fc6d73086014b99a7717c Mon Sep 17 00:00:00 2001 From: Julio Castillo Date: Tue, 5 Apr 2022 15:38:44 +0200 Subject: [PATCH 2/3] Silence linter --- tests/doc_examples/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/doc_examples/__init__.py b/tests/doc_examples/__init__.py index e69de29bb..6d6d1266c 100644 --- a/tests/doc_examples/__init__.py +++ b/tests/doc_examples/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. From 0b87622586877275c274518177c9ae2cefe39625 Mon Sep 17 00:00:00 2001 From: Julio Castillo Date: Tue, 5 Apr 2022 15:41:57 +0200 Subject: [PATCH 3/3] Fix tests --- examples/factories/project-factory/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/factories/project-factory/main.tf b/examples/factories/project-factory/main.tf index 2bbd78eb4..774fc1d64 100644 --- a/examples/factories/project-factory/main.tf +++ b/examples/factories/project-factory/main.tf @@ -24,7 +24,7 @@ locals { } _group_iam_bindings = distinct(flatten(values(var.group_iam))) # internal structures for project service accounts IAM bindings - _project_id = coalesce(var.prefix, "") == "" ? var.project_id : "${var.prefix}-${var.project_id}" + _project_id = var.prefix == null || var.prefix == "" ? var.project_id : "${var.prefix}-${var.project_id}" _service_accounts_iam = { for r in local._service_accounts_iam_bindings : r => [ for k, v in var.service_accounts :