From 359dcfadb70b8ae4fb16077e3742b1b03868b80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jasmin=20M=C3=BCller?= Date: Fri, 9 Dec 2022 13:18:21 +0100 Subject: [PATCH] feat(user): add optional random password variable INPRO-1451 --- README.md | 1 + main.tf | 3 ++- modules/users/main.tf | 3 +++ modules/users/variables.tf | 6 ++++++ variables.tf | 6 ++++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b49458c..0baae32 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ No resources. | [group\_settings](#input\_group\_settings) | contains all defined group setting templates for Google Groups | n/a | yes | | [groups](#input\_groups) | contains objects representing all defined Google Groups | n/a | yes | | [users](#input\_users) | contains objects representing all defined Google Users | n/a | yes | +| [random\_password](#input\_random\_password) | contains a random password required for Users | `null` | no | | [users\_external](#input\_users\_external) | contains objects representing all defined external Users | `{}` | no | ## Outputs diff --git a/main.tf b/main.tf index 669121b..39e7bca 100644 --- a/main.tf +++ b/main.tf @@ -51,7 +51,8 @@ module "users" { providers = { googleworkspace = googleworkspace } - user = each.value + user = each.value + random_password = var.random_password } module "users_external_to_groups" { diff --git a/modules/users/main.tf b/modules/users/main.tf index 88ae0db..4d370de 100644 --- a/modules/users/main.tf +++ b/modules/users/main.tf @@ -17,6 +17,8 @@ resource "googleworkspace_user" "user" { family_name = var.user.family_name given_name = var.user.given_name } + password = var.user.password != null ? var.user.password : var.random_password + aliases = var.user.aliases archived = var.user.archived include_in_global_address_list = var.user.include_in_global_address_list @@ -27,6 +29,7 @@ resource "googleworkspace_user" "user" { lifecycle { ignore_changes = [ + password, recovery_email, recovery_phone, ] diff --git a/modules/users/variables.tf b/modules/users/variables.tf index 8759982..d27bd9a 100644 --- a/modules/users/variables.tf +++ b/modules/users/variables.tf @@ -20,3 +20,9 @@ variable "user" { roles : optional(list(string)), }) } + +variable "random_password" { + description = "contains a random password required for Users" + type = string + default = null +} diff --git a/variables.tf b/variables.tf index 7668f63..030c172 100644 --- a/variables.tf +++ b/variables.tf @@ -59,6 +59,12 @@ variable "users" { })) } +variable "random_password" { + description = "contains a random password required for Users" + type = string + default = null +} + variable "users_external" { description = "contains objects representing all defined external Users" type = map(object({