Skip to content

Commit

Permalink
Reworked SA roles for old-projects cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpalamarchuk committed Nov 8, 2019
1 parent 4c6c87c commit b83b1e9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion modules/project_cleanup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,23 @@ resource "google_service_account" "project_cleaner_function" {
display_name = "Project Cleaner Function"
}

module "sa-organization-roles" {
source = "terraform-google-modules/iam/google//modules/organizations_iam"
version = "4.0.0"
organizations = [var.organization_id]
mode = "additive"

bindings = {
"roles/resourcemanager.projectDeleter" = ["serviceAccount:${google_service_account.project_cleaner_function.email}"]
"roles/resourcemanager.folderViewer" = ["serviceAccount:${google_service_account.project_cleaner_function.email}"]
"roles/resourcemanager.lienModifier" = ["serviceAccount:${google_service_account.project_cleaner_function.email}"]
}
}

resource "google_organization_iam_member" "project_owner" {
count = length(local.org_roles)
org_id = var.organization_id
role = "roles/owner"
role = local.org_roles[count.index]
member = "serviceAccount:${google_service_account.project_cleaner_function.email}"
}

Expand Down

0 comments on commit b83b1e9

Please sign in to comment.