You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: docs/index.md
+42-15Lines changed: 42 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,32 +20,59 @@ provider "googleworkspace" {
20
20
}
21
21
```
22
22
23
+
## Authorization
24
+
This provider uses [Admin SDK](https://developers.google.com/admin-sdk) API methods to manage resources on a Workspace customer domain. There are multiple ways to set up proper authorization for a service account:
25
+
26
+
* Enable [domain-wide delegation](#using-domain-wide-delegation) to impersonate a user that has super administrator privileges. You cannot directly grant super administrator privileges to service accounts.
27
+
28
+
* Assign [specific administrator roles](https://support.google.com/a/answer/9807615?hl=en&ref_topic=9832445) directly to the service account.
29
+
23
30
## Authentication
24
31
25
-
### Creating a Service Account and Credentials
32
+
### Using Domain-Wide Delegation
33
+
34
+
#### Creating a Service Account and Credentials
35
+
36
+
Terraform uses a GCP service account to manage resources created by the provider. To create the service account and generate a service account key:
26
37
27
-
Terraform will use a GCP service account to manage resources created by the provider. To create the service account and
28
-
generate a service account key see the documentation [here](https://developers.google.com/admin-sdk/directory/v1/guides/delegation#create_the_service_account_and_credentials).
29
-
Once the key has been generated, save the json file locally and set the `GOOGLEWORKSPACE_CREDENTIALS` environment
30
-
variable to the path of the service account key. Terraform will use that key for authentication.
38
+
1. Follow the instructions in the [create service account and credentials documentation](https://developers.google.com/admin-sdk/directory/v1/guides/delegation#create_the_service_account_and_credentials).
39
+
2. Save the json file containing your service account key credentials locally and set the `GOOGLEWORKSPACE_CREDENTIALS` environment variable to the path of that file. Terraform will now use that key for authentication.
31
40
32
-
### Configuring the Service Account
41
+
####Configuring the Service Account
33
42
34
43
To access user data on a Google Workspace domain, the service account that you created needs to be granted access
35
-
by a super administrator for the domain. To delegate domain-wide authority to a service account, follow the instructions
* Note: The Oauth scopes granted to your service account must match, or be a superset, of the `oauth_scopes` granted to
39
48
the `googleworkspace` provider.
40
49
41
-
### Impersonating a Google Workspace User
50
+
#### Impersonating a Google Workspace User
51
+
52
+
Only users with access to the Admin APIs can access the Admin SDK Directory API, therefore your service account needs to impersonate one of those users to access the Admin SDK Directory API. This user's email
53
+
must be set in the environment variable `GOOGLEWORKSPACE_IMPERSONATED_USER_EMAIL` or in the `impersonated_user_email` attribute in the provider. Additionally, the user must have logged in at least once and accepted the Google Workspace Terms of Service.
54
+
55
+
### Using Specific Administrator Roles
56
+
You do not need to set up domain-wide delegation if you are granting more specific administrator roles to the service account. If the Terraform pipeline execution environment provides an appropriate token as Application Default Credentials (ADC), you can use the provider without any further setup.
57
+
58
+
When using gcloud locally, you can provide the required scopes for ADC login by adding the `--scopes` parameter to [`gcloud auth application-default login`](https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login). For example, you can [provide additional scopes](https://cloud.google.com/sdk/gcloud/reference/beta/compute/instances/set-scopes) on Compute Engine. You can do this to configure access for both service accounts and end users.
59
+
60
+
```terraform
61
+
provider "googleworkspace" {
62
+
customer_id = "A01b123xz"
63
+
}
64
+
```
65
+
66
+
The approach outlined above does not work on Cloud Build because it does not (yet) support specifying additional scopes for service account tokens accessible during builds. Other pipeline setups use the `google_service_account_access_token` to impersonate a service account. This allows them to use a single identity regardless of who is initiating the execution. For these cases, set the `access_token` parameter to the appropriate credentials.
0 commit comments