Skip to content

Commit

Permalink
New: add groups-in-group membership functionality INPRO-365
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzlyn committed Apr 23, 2021
1 parent d4f19d0 commit 1930a62
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ role:
name: 'Example Role'
```
##### Groups in Group example structure
Group member have to be defined within the group definition.
```yaml
role:
email: '[email protected]'
name: 'Example Role'
groups:
- alt_role
```
In this example the group 'alt_role' will be a member of the group 'role'.
#### **Users example structure**
```yaml
jane:
Expand Down
28 changes: 28 additions & 0 deletions groups_in_group/groups_in_group.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
terraform {
required_providers {
gsuite = {
source = "DeviaVir/gsuite"
version = "0.1.58"
}
}
}

variable "groups" {
type = map(any)
description = "contains objects representing all defined Google Groups"
}

variable "group" {
type = any
description = "contains an object representing a Google Group"
}

/**
* Ressource documentation: https://registry.terraform.io/providers/DeviaVir/gsuite/latest/docs/resources/group
*/

resource "gsuite_group_member" "member" {
for_each = toset(var.group.groups)
group = var.group.email
email = var.groups[each.value].email
}
11 changes: 11 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ module "groups" {
group = each.value
}

module "groups_in_group" {
for_each = var.groups
depends_on = [module.groups]
source = "./groups_in_group"
providers = {
gsuite = gsuite
}
groups = var.groups
group = each.value
}

module "users" {
for_each = var.users
depends_on = [module.groups]
Expand Down

0 comments on commit 1930a62

Please sign in to comment.