Skip to content

Commit

Permalink
feat(user): add optional random password variable INPRO-1451
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzlyn committed Dec 9, 2022
1 parent 5c388f8 commit 359dcfa
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ No resources.
| <a name="input_group_settings"></a> [group\_settings](#input\_group\_settings) | contains all defined group setting templates for Google Groups | n/a | yes |
| <a name="input_groups"></a> [groups](#input\_groups) | contains objects representing all defined Google Groups | n/a | yes |
| <a name="input_users"></a> [users](#input\_users) | contains objects representing all defined Google Users | n/a | yes |
| <a name="input_random_password"></a> [random\_password](#input\_random\_password) | contains a random password required for Users | `null` | no |
| <a name="input_users_external"></a> [users\_external](#input\_users\_external) | contains objects representing all defined external Users | `{}` | no |

## Outputs
Expand Down
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
3 changes: 3 additions & 0 deletions modules/users/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,6 +29,7 @@ resource "googleworkspace_user" "user" {

lifecycle {
ignore_changes = [
password,
recovery_email,
recovery_phone,
]
Expand Down
6 changes: 6 additions & 0 deletions modules/users/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 359dcfa

Please sign in to comment.