Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 0-bootstrap iam_by_principals not taking into account all principals #2267

Merged
merged 3 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions fast/stages/0-bootstrap/organization.tf
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,14 @@ module "organization" {
organization_id = module.organization-logging.id
# human (groups) IAM bindings
iam_by_principals = {
for k, v in local.iam_principals :
k => distinct(concat(v, lookup(var.iam_by_principals, k, [])))
for key in distinct(concat(
keys(local.iam_principals),
keys(var.iam_by_principals),
)) :
key => distinct(concat(
lookup(local.iam_principals, key, []),
lookup(var.iam_by_principals, key, []),
))
}
# machine (service accounts) IAM bindings
iam = merge(
Expand Down
2 changes: 1 addition & 1 deletion tests/collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def runtest(self):
self.tf_var_files, self.extra_files)
except AssertionError:
def full_paths(x):
return [(self.parent.path.parent / x ) for x in x]
return [str(self.parent.path.parent / x ) for x in x]
print(f'Error in inventory file: {" ".join(full_paths(self.inventory))}')
print(f'To regenerate inventory run: python tools/plan_summary.py {self.module} {" ".join(full_paths(self.tf_var_files))}')
raise
Expand Down
20 changes: 20 additions & 0 deletions tests/fast/stages/s0_bootstrap/iam_by_principals.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
organization = {
domain = "fast.example.com"
id = 123456789012
customer_id = "C00000000"
}
billing_account = {
id = "000000-111111-222222"
}
essential_contacts = "[email protected]"
iam_by_principals = {
"user:[email protected]" = ["roles/browser"]
}
prefix = "fast"
org_policies_config = {
import_defaults = false
}
outputs_location = "/fast-config"
groups = {
gcp-support = "group:[email protected]"
}
22 changes: 22 additions & 0 deletions tests/fast/stages/s0_bootstrap/iam_by_principals.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 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.

values:
module.organization.google_organization_iam_binding.authoritative["roles/browser"]:
condition: []
members:
- domain:fast.example.com
- user:[email protected]
org_id: '123456789012'
role: roles/browser
2 changes: 2 additions & 0 deletions tests/fast/stages/s0_bootstrap/tftest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ tests:
- simple.yaml
- simple_projects.yaml
- simple_sas.yaml

iam_by_principals:
Loading