Skip to content

feat: copy over code from old mp module #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,3 @@
# Changelog

## [0.7.0](https://github.com/masterpointio/terraform-module-template/compare/v0.6.0...v0.7.0) (2025-05-07)


### Features

* GHA, trunk and renovate updates ([#34](https://github.com/masterpointio/terraform-module-template/issues/34)) ([b16fa86](https://github.com/masterpointio/terraform-module-template/commit/b16fa86ea444eb1464c443324908b284a7842861))

## [0.6.0](https://github.com/masterpointio/terraform-module-template/compare/v0.5.1...v0.6.0) (2025-04-30)


### Features

* **gha:** oidc aws credentials if AWS provider is used ([#29](https://github.com/masterpointio/terraform-module-template/issues/29)) ([4f8f1ad](https://github.com/masterpointio/terraform-module-template/commit/4f8f1adec3274960a11ee7277296e88d662c8036))

## [0.5.1](https://github.com/masterpointio/terraform-module-template/compare/v0.5.0...v0.5.1) (2025-04-30)


### Bug Fixes

* **renovate:** valid regex ([#30](https://github.com/masterpointio/terraform-module-template/issues/30)) ([224acea](https://github.com/masterpointio/terraform-module-template/commit/224aceac5b841ab78c22ba42b7c3d74edae90b26))

## [0.5.0](https://github.com/masterpointio/terraform-module-template/compare/v0.4.0...v0.5.0) (2025-04-24)


### Features

* upgrade terraform docs ([#23](https://github.com/masterpointio/terraform-module-template/issues/23)) ([475707f](https://github.com/masterpointio/terraform-module-template/commit/475707f7d6eef8bde27bca632cba25a535010fdc))

## [0.4.0](https://github.com/masterpointio/terraform-module-template/compare/v0.3.0...v0.4.0) (2025-04-16)


### Features

* setup connection to notion db ([#21](https://github.com/masterpointio/terraform-module-template/issues/21)) ([857df50](https://github.com/masterpointio/terraform-module-template/commit/857df5042fbde3d3e9ffbfc964eae9f7a7927cb0))

## [0.3.0](https://github.com/masterpointio/terraform-module-template/compare/v0.2.0...v0.3.0) (2025-04-10)


### Features

* actualize README template ([#15](https://github.com/masterpointio/terraform-module-template/issues/15)) ([5d8de5f](https://github.com/masterpointio/terraform-module-template/commit/5d8de5fcf98b255ed65201b1ab2036ebf92ca138))
* **renovate:** enables renovate terraform manager ([#18](https://github.com/masterpointio/terraform-module-template/issues/18)) ([e45f5ac](https://github.com/masterpointio/terraform-module-template/commit/e45f5acf08195f45ac9d4fe23447c600230ba4b4))


### Bug Fixes

* **renovate:** schedule update ([#20](https://github.com/masterpointio/terraform-module-template/issues/20)) ([62d7e24](https://github.com/masterpointio/terraform-module-template/commit/62d7e24aa39312565c894525ef5c0ebb1053eb74))

## [0.2.0](https://github.com/masterpointio/terraform-module-template/compare/v0.1.1...v0.2.0) (2024-11-14)


### Features

* adds GH + CRabbit configs ([d86d463](https://github.com/masterpointio/terraform-module-template/commit/d86d463385d501db5465b02de13d60c925b5815d))

## [0.1.1](https://github.com/masterpointio/terraform-module-template/compare/0.1.0...v0.1.1) (2024-08-15)


### Bug Fixes

* remove markdown trailing whitespace ([d609646](https://github.com/masterpointio/terraform-module-template/commit/d6096463b916eb536603d4ca3b2f3315e3fec9f2))
* removes redundant editorconfig settings ([bbe0050](https://github.com/masterpointio/terraform-module-template/commit/bbe0050450cece8074f3d9ff5c3bd72ff01d8a1b))
102 changes: 80 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,83 @@
[![Banner][banner-image]](https://masterpoint.io/)

# terraform-module-template
# terraform-googleworkspace-users-groups-automation

[![Release][release-badge]][latest-release]

💡 Learn more about Masterpoint [below](#who-we-are-𐦂𖨆𐀪𖠋).

## Purpose and Functionality

This repository serves as a template for creating Terraform modules, providing a standardized structure and essential files for efficient module development. It's designed to ensure consistency and our best practices across Terraform projects.
Use this [child module](https://opentofu.org/docs/language/modules/#child-modules) to manage Google Workspace users, groups, and roles.

## Usage

### Prerequisites (optional)
If you want to use this module with an existing Google Workspace, see the [import-existing-org](examples/import-existing-org) example, which demonstrates how to import your existing Google users and groups.

TODO
## Usage

### Step-by-Step Instructions

TODO
There are two provider authentication methods available:

1. Authenticate using a Google Cloud service account key file.
2. Authenticate using a Google Cloud service account key file and impersonate a real user with Super Admin privileges.

We recommend method (2), impersonating a Super Admin, as this allows you to grant Admin privileges to users (service accounts cannot do this). To set this up, follow the [Domain-Wide Delegation authentication instructions](https://github.com/hashicorp/terraform-provider-googleworkspace/blob/main/docs/index.md#using-domain-wide-delegation).

Follow the provider [authentication setup instructions](https://github.com/hashicorp/terraform-provider-googleworkspace/blob/main/docs/index.md#google-workspace-provider).

Once you've completed the setup process, your provider block should look like this:

```hcl
provider "googleworkspace" {
# Use 'my_customer' as an alias for your account's customerId to ensure compatibility with Google's API
# For example, custom schemas on the user object will fail if the customer_id is set to your actual customer_id
# For more details: https://developers.google.com/workspace/admin/directory/reference/rest/v1/schemas/get
customer_id = "my_customer"

credentials = "/path/to/credentials/my-google-project-credentials-1234567890.json"
impersonated_user_email = "my_impersonated_user_email@my_domain.com"

oauth_scopes = [
"https://www.googleapis.com/auth/admin.directory.group",
"https://www.googleapis.com/auth/admin.directory.user",
"https://www.googleapis.com/auth/admin.directory.userschema",
"https://www.googleapis.com/auth/apps.groups.settings",
"https://www.googleapis.com/auth/iam",
]
}
```

## Example

```hcl
module "googleworkspace_users_groups" {
source = "git::https://github.com/masterpointio/terraform-googleworkspace-users-groups-automation.git"

users = {
"first.last@example.com" = {
primary_email = "first.last@example.com"
family_name = "Last"
given_name = "First"
password = "example-password"
groups = {
"platform" = {
role = "member"
}
}
}
}

groups = {
"platform" = {
name = "Platform"
email = "platform@example.com"
settings = {
who_can_join = "ALL_IN_DOMAIN_CAN_JOIN"
}
}
}
}
```

<!-- prettier-ignore-start -->
<!-- markdownlint-disable MD013 -->
Expand All @@ -28,13 +87,13 @@ TODO
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.0 |
| <a name="requirement_googleworkspace"></a> [googleworkspace](#requirement\_googleworkspace) | >= 0.7.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.0 |
| <a name="provider_googleworkspace"></a> [googleworkspace](#provider\_googleworkspace) | >= 0.7.0 |

## Modules

Expand All @@ -46,7 +105,10 @@ TODO

| Name | Type |
|------|------|
| [random_pet.template](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) | resource |
| [googleworkspace_group.defaults](https://registry.terraform.io/providers/hashicorp/googleworkspace/latest/docs/resources/group) | resource |
| [googleworkspace_group_member.user_to_groups](https://registry.terraform.io/providers/hashicorp/googleworkspace/latest/docs/resources/group_member) | resource |
| [googleworkspace_group_settings.defaults](https://registry.terraform.io/providers/hashicorp/googleworkspace/latest/docs/resources/group_settings) | resource |
| [googleworkspace_user.defaults](https://registry.terraform.io/providers/hashicorp/googleworkspace/latest/docs/resources/user) | resource |

## Inputs

Expand All @@ -59,24 +121,23 @@ TODO
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br/>Map of maps. Keys are names of descriptors. Values are maps of the form<br/>`{<br/> format = string<br/> labels = list(string)<br/>}`<br/>(Type is `any` so the map values can later be enhanced to provide additional options.)<br/>`format` is a Terraform format string to be passed to the `format()` function.<br/>`labels` is a list of labels, in order, to pass to `format()` function.<br/>Label values will be normalized before being passed to `format()` so they will be<br/>identical to how they appear in `id`.<br/>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
| <a name="input_groups"></a> [groups](#input\_groups) | List of groups | <pre>map(object({<br/> name : string,<br/> description : optional(string),<br/> email : string,<br/> timeouts : optional(object({<br/> create : optional(string),<br/> update : optional(string),<br/> }), {<br/> create = null<br/> update = null<br/> }),<br/> # https://registry.terraform.io/providers/hashicorp/googleworkspace/latest/docs/resources/group_settings<br/> settings : optional(object({<br/> allow_external_members : optional(bool),<br/> allow_web_posting : optional(bool),<br/> archive_only : optional(bool),<br/> custom_footer_text : optional(string),<br/> custom_reply_to : optional(string),<br/> default_message_deny_notification_text : optional(string),<br/> enable_collaborative_inbox : optional(bool),<br/> include_custom_footer : optional(bool),<br/> include_in_global_address_list : optional(bool),<br/> is_archived : optional(bool),<br/> members_can_post_as_the_group : optional(bool),<br/> message_moderation_level : optional(string),<br/> primary_language : optional(string),<br/> reply_to : optional(string),<br/> send_message_deny_notification : optional(bool),<br/> spam_moderation_level : optional(string),<br/> who_can_assist_content : optional(string),<br/> who_can_contact_owner : optional(string),<br/> who_can_discover_group : optional(string),<br/> who_can_join : optional(string),<br/> who_can_leave_group : optional(string),<br/> who_can_moderate_content : optional(string),<br/> who_can_moderate_members : optional(string),<br/> who_can_post_message : optional(string),<br/> who_can_view_group : optional(string),<br/> who_can_view_membership : optional(string),<br/> }), {}),<br/> }))</pre> | `{}` | no |
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br/>Set to `0` for unlimited length.<br/>Set to `null` for keep the existing setting, which defaults to `0`.<br/>Does not affect `id_full`. | `number` | `null` | no |
| <a name="input_label_key_case"></a> [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.<br/>Does not affect keys of tags passed in via the `tags` input.<br/>Possible values: `lower`, `title`, `upper`.<br/>Default value: `title`. | `string` | `null` | no |
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br/>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br/>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
| <a name="input_label_value_case"></a> [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,<br/>set as tag values, and output by this module individually.<br/>Does not affect values of tags passed in via the `tags` input.<br/>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br/>Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.<br/>Default value: `lower`. | `string` | `null` | no |
| <a name="input_labels_as_tags"></a> [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.<br/>Default is to include all labels.<br/>Tags with empty values will not be included in the `tags` output.<br/>Set to `[]` to suppress all generated tags.<br/>**Notes:**<br/> The value of the `name` tag, if included, will be the `id`, not the `name`.<br/> Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be<br/> changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` | <pre>[<br/> "default"<br/>]</pre> | no |
| <a name="input_length"></a> [length](#input\_length) | The length of the random name | `number` | `2` | no |
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br/>This is the only ID element not also included as a `tag`.<br/>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br/>Characters matching the regex will be removed from the ID elements.<br/>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br/>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
| <a name="input_users"></a> [users](#input\_users) | List of users | <pre>map(object({<br/> # addresses<br/> aliases : optional(list(string), []),<br/> archived : optional(bool, false),<br/> change_password_at_next_login : optional(bool),<br/> # custom_schemas<br/> # emails<br/> # external_ids<br/> family_name : string,<br/> given_name : string,<br/> groups : optional(map(object({<br/> role : optional(string, "MEMBER"),<br/> delivery_settings : optional(string, "ALL_MAIL"),<br/> type : optional(string, "USER"),<br/> })), {}),<br/> # ims<br/> include_in_global_address_list : optional(bool),<br/> ip_allowlist : optional(bool),<br/> is_admin : optional(bool),<br/> # keywords<br/> # languages<br/> # locations<br/> org_unit_path : optional(string),<br/> # organizations<br/> # phones<br/> # posix_accounts<br/> primary_email : string,<br/> recovery_email : optional(string),<br/> recovery_phone : optional(string),<br/> # relations<br/> # ssh_public_keys<br/> suspended : optional(bool),<br/> # timeouts<br/> # websites<br/><br/> # User attributes with unique constraints<br/><br/> # password and hash_function<br/> # If a hashFunction is specified, the password must be a valid hash key.<br/> # If it's not specified, the password should be in clear text and between<br/> # 8–100 ASCII characters.<br/> # https://developers.google.com/workspace/admin/directory/v1/guides/manage-users<br/> hash_function : optional(string),<br/> password : optional(string),<br/> }))</pre> | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_random_pet_name"></a> [random\_pet\_name](#output\_random\_pet\_name) | The generated random pet name |
No outputs.
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- markdownlint-enable MD013 -->
<!-- prettier-ignore-end -->
Expand Down Expand Up @@ -138,11 +199,8 @@ Copyright © 2016-2025 [Masterpoint Consulting LLC](https://masterpoint.io/)
[newsletter-url]: https://newsletter.masterpoint.io/
[youtube-badge]: https://img.shields.io/badge/YouTube-Subscribe-D191BF?style=for-the-badge&logo=youtube&logoColor=white
[youtube-url]: https://www.youtube.com/channel/UCeeDaO2NREVlPy9Plqx-9JQ

<!-- TODO: Replace `terraform-module-template` with your actual repository name. -->

[release-badge]: https://img.shields.io/github/v/release/masterpointio/terraform-module-template?color=0E383A&label=Release&style=for-the-badge&logo=github&logoColor=white
[latest-release]: https://github.com/masterpointio/terraform-module-template/releases/latest
[contributors-image]: https://contrib.rocks/image?repo=masterpointio/terraform-module-template
[contributors-url]: https://github.com/masterpointio/terraform-module-template/graphs/contributors
[issues-url]: https://github.com/masterpointio/terraform-module-template/issues
[release-badge]: https://img.shields.io/github/v/release/masterpointio/terraform-googleworkspace-users-groups-automation?color=0E383A&label=Release&style=for-the-badge&logo=github&logoColor=white
[latest-release]: https://github.com/masterpointio/terraform-googleworkspace-users-groups-automation/releases/latest
[contributors-image]: https://contrib.rocks/image?repo=masterpointio/terraform-googleworkspace-users-groups-automation
[contributors-url]: https://github.com/masterpointio/terraform-googleworkspace-users-groups-automation/graphs/contributors
[issues-url]: https://github.com/masterpointio/terraform-googleworkspace-users-groups-automation/issues
Loading