-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove default SA editor role from Seed and CICD projects (#896)
* remove Editor from Seed and CICD projects * code review fixes * Apply suggestions from code review Co-authored-by: Bharath KKB <bharathkrishnakb@gmail.com>
- Loading branch information
1 parent
8bd7d14
commit 465d3dd
Showing
4 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
locals { | ||
org_id = var.parent_type == "organization" ? var.parent_id : "" | ||
folder_id = var.parent_type == "folder" ? var.parent_id : "" | ||
project_id = var.parent_type == "project" ? var.parent_id : "" | ||
} | ||
|
||
resource "google_organization_iam_binding" "iam_remove" { | ||
for_each = toset(var.parent_type == "organization" ? var.roles : []) | ||
|
||
org_id = local.org_id | ||
role = each.key | ||
members = [] | ||
} | ||
|
||
resource "google_folder_iam_binding" "iam_remove" { | ||
for_each = toset(var.parent_type == "folder" ? var.roles : []) | ||
|
||
folder = local.folder_id | ||
role = each.key | ||
members = [] | ||
} | ||
|
||
resource "google_project_iam_binding" "iam_remove" { | ||
for_each = toset(var.parent_type == "project" ? var.roles : []) | ||
|
||
project = local.project_id | ||
role = each.key | ||
members = [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
variable "parent_type" { | ||
description = "Type of the parent resource. valid values are `organization`, `folder`, and `project`." | ||
type = string | ||
|
||
validation { | ||
condition = contains(["organization", "folder", "project"], var.parent_type) | ||
error_message = "For parent_type only `organization`, `folder`, and `project` are valid." | ||
} | ||
} | ||
|
||
variable "parent_id" { | ||
description = "ID of the parent resource." | ||
type = string | ||
} | ||
|
||
variable "roles" { | ||
description = "Roles to remove all members in the parent resource." | ||
type = list(string) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
terraform { | ||
required_version = ">= 0.13" | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = ">= 3.77" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters