Skip to content

Commit

Permalink
Fix bug in gsuite_group module that requires organizationViewer role
Browse files Browse the repository at this point in the history
organizationViewer role should not be necessary if domain is specified.
  • Loading branch information
Simon So committed Mar 22, 2019
1 parent cdd1751 commit dadf88c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def asdict(self):
class OrgPermissions:
# Permissions that the service account must have for any organization
ALL_PERMISSIONS = [
# Typically granted with `roles/resourcemanager.organizationViewer`
# Typically granted with `roles/resourcemanager.organizationViewer`
"resourcemanager.organizations.get",
]

Expand Down Expand Up @@ -132,7 +132,7 @@ def validate(self, credentials):
"Service account permissions on organization",
resource,
self.permissions,
response.get("permissions", []),
response.get("permissions", [])
)

return req.asdict()
Expand Down Expand Up @@ -209,7 +209,7 @@ def validate(self, credentials):
"Service account permissions on host VPC project",
resource,
self.permissions,
response.get("permissions", []),
response.get("permissions", [])
)

return req.asdict()
Expand Down Expand Up @@ -295,7 +295,7 @@ def validate(self, credentials):
"Service account permissions on billing account",
resource,
self.REQUIRED_PERMISSIONS,
response["permissions"],
response["permissions"]
)

return req.asdict()
Expand Down
6 changes: 4 additions & 2 deletions modules/gsuite_group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/

locals {
domain = "${var.domain != "" ? var.domain : data.google_organization.org.domain}"
email = "${format("%s@%s", var.name, local.domain)}"
domain_list = "${concat(data.google_organization.org.*.domain, list("dummy"))}"
domain = "${var.domain == "" ? element(local.domain_list, 0) : var.domain}"
email = "${format("%s@%s", var.name, local.domain)}"
}

/*****************************************
Organization info retrieval
*****************************************/
data "google_organization" "org" {
count = "${var.domain == "" ? 1 : 0}"
organization = "${var.org_id}"
}

0 comments on commit dadf88c

Please sign in to comment.