Skip to content

Commit

Permalink
Merge pull request terraform-google-modules#141 from thefirstofthe300…
Browse files Browse the repository at this point in the history
…/master

Fix a race condition when creating a new G Suite group
  • Loading branch information
morgante authored Feb 21, 2019
2 parents 627994d + b709706 commit edd458f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# Python
*.pyc
# Python virtualenv
venv

# Emacs save files
*~
Expand Down
2 changes: 2 additions & 0 deletions modules/core_project_factory/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ resource "google_compute_shared_vpc_service_project" "shared_vpc_attachment" {
*****************************************/
data "google_compute_default_service_account" "default" {
project = "${google_project.main.id}"

depends_on = ["google_project_service.project_services"]
}

/******************************************
Expand Down
14 changes: 1 addition & 13 deletions modules/gsuite_enabled/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ resource "gsuite_group_member" "service_account_sa_group_member" {
group = "${var.sa_group}"
email = "${module.project-factory.service_account_email}"
role = "MEMBER"

depends_on = ["module.project-factory"]
}

/*****************************************
Expand All @@ -40,17 +38,7 @@ module "gsuite_group" {
domain = "${var.domain}"
name = "${local.group_name}"
org_id = "${var.org_id}"
}

/******************************************
Gsuite Group Configuration
*****************************************/
resource "gsuite_group" "group" {
count = "${var.create_group ? 1 : 0}"

description = "${var.name} project group"
email = "${module.gsuite_group.email}"
name = "${local.group_name}"
create_group = "${var.create_group}"
}

/***********************************************
Expand Down
11 changes: 11 additions & 0 deletions modules/gsuite_group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ locals {
data "google_organization" "org" {
organization = "${var.org_id}"
}

/******************************************
Gsuite Group Configuration
*****************************************/
resource "gsuite_group" "group" {
count = "${var.create_group ? 1 : 0}"

description = "${var.name} project group"
email = "${local.email}"
name = "${var.name}"
}
2 changes: 1 addition & 1 deletion modules/gsuite_group/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ output "domain" {

output "email" {
description = "The email address of the group."
value = "${local.email}"
value = "${element(compact(concat(gsuite_group.group.*.email, list(local.email))), 0)}"
}
5 changes: 5 additions & 0 deletions modules/gsuite_group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ variable "name" {
variable "org_id" {
description = "The organization ID."
}

variable "create_group" {
description = "Whether to create the group or not"
default = "false"
}

0 comments on commit edd458f

Please sign in to comment.