-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: add examples for data structure and module usage INPRO-358
- Loading branch information
Showing
9 changed files
with
161 additions
and
4 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,15 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# PROVIDE CREDENTIALS TO GSUITE PROVIDER | ||
# Credentials are stored in terraform.tfvars file. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
provider "gsuite" { | ||
impersonated_user_email = var.impersonated_user_email | ||
credentials = var.credentials | ||
oauth_scopes = [ | ||
"https://www.googleapis.com/auth/admin.directory.group", | ||
"https://www.googleapis.com/auth/apps.groups.settings", | ||
"https://www.googleapis.com/auth/admin.directory.user", | ||
"https://www.googleapis.com/auth/admin.directory.userschema", | ||
] | ||
} |
2 changes: 2 additions & 0 deletions
2
examples/example-gsuite-authentication/terraform.tfvars.example
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,2 @@ | ||
#impersonated_user_email = "[email protected]" | ||
#credentials = "/path/to/google_credentials.json" |
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,11 @@ | ||
variable "impersonated_user_email" { | ||
type = string | ||
default = null | ||
description = "impersonated user account for GSuite domain-wide delegation" | ||
} | ||
|
||
variable "credentials" { | ||
type = string | ||
default = null | ||
description = "links to google credentials for service account" | ||
} |
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,53 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# MANAGE USERS AND GROUPS IN GOOGLE WORKSPACE | ||
# These templates show an example of how to use the terraform-gsuite-user-group-management module to manage Users and | ||
# Groups in Google Workspace. Google Buckets are used as data source. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
terraform { | ||
required_providers { | ||
gsuite = { | ||
source = "DeviaVir/gsuite" | ||
version = "0.1.58" | ||
} | ||
google = { | ||
source = "hashicorp/google" | ||
version = "3.66.1" | ||
} | ||
} | ||
} | ||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# ADD CREDENTIALS FOR GSUITE PROVIDER | ||
# See example-gsuite-authentication | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# DATA SOURCE FROM GOOGLE BUCKET | ||
# YAML files are stored in Google Buckets with versioning enabled. Each YAML file gets its own reference. For YAML | ||
# example files see example-yaml-files. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
data "google_storage_bucket_object_content" "groups" { | ||
name = "groups.yaml" | ||
bucket = "example-data" | ||
} | ||
|
||
data "google_storage_bucket_object_content" "users" { | ||
name = "users.yaml" | ||
bucket = "example-data" | ||
} | ||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# GOOGLE WORKSPACE USER-GROUP MANAGEMENT MODULE | ||
# The original Github Repo is used as source to ensure future updates. The module expects groups and users data. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
module "gworkspace" { | ||
source = "[email protected]:strg-at/terraform-google-workspace-module.git" | ||
providers = { | ||
gsuite = gsuite | ||
} | ||
groups = yamldecode(data.google_storage_bucket_object_content.groups.content) | ||
users = yamldecode(data.google_storage_bucket_object_content.users.content) | ||
} |
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,43 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# MANAGE USERS AND GROUPS IN GOOGLE WORKSPACE | ||
# These templates show an example of how to use the terraform-gsuite-user-group-management module to manage Users and | ||
# Groups in Google Workspace. Local YAML files are used as data source. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
terraform { | ||
required_providers { | ||
gsuite = { | ||
source = "DeviaVir/gsuite" | ||
version = "0.1.58" | ||
} | ||
} | ||
} | ||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# ADD CREDENTIALS FOR GSUITE PROVIDER | ||
# See example-gsuite-authentication | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# DATA SOURCE FROM LOCAL | ||
# YAML files are stored locally. For YAML example files see example-yaml-files. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
locals { | ||
groups = yamldecode(file("${path.module}/groups.yaml")) | ||
users = yamldecode(file("${path.module}/users.yaml")) | ||
} | ||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# GOOGLE WORKSPACE USER-GROUP MANAGEMENT MODULE | ||
# The original Github Repo is used as source to ensure future updates. The module expects groups and users data. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
module "gworkspace" { | ||
source = "[email protected]:strg-at/terraform-google-workspace-module.git" | ||
providers = { | ||
gsuite = gsuite | ||
} | ||
groups = local.groups | ||
users = local.users | ||
} |
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,17 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# GOOGLE GROUP | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
one-group: | ||
email: '[email protected]' | ||
name: 'Example group' | ||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# GOOGLE GROUP WITH ANOTHER GROUP AS MEMBER | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
another-group: | ||
email: '[email protected]' | ||
name: 'Another Example group' | ||
groups: | ||
- one-group |
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,16 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# GOOGLE USER WITH GROUP MEMBERSHIPS | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
jane: | ||
family_name: 'Doe' | ||
given_name: 'Jane' | ||
primary_email: '[email protected]' | ||
recovery_email: '[email protected]' | ||
recovery_phone: '+10000' | ||
org_unit_path: / | ||
is_suspended: false | ||
suspension_reason: '' | ||
role: | ||
- group | ||
- another-group |
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
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