Set up service account authentication for Google Drive
Service account authentication (SERVICE_ACCOUNT) is the recommended
method for a Google Drive data source. A Google Cloud service account authenticates
with a private key, then impersonates a Google Workspace admin user to crawl Drive
content for any user in your domain. This is the only method that supports
document-level access control (ACLs).
Administrative access required
This setup requires a Google Workspace administrator to enable APIs, create the service account, configure domain-wide delegation, and create a delegated admin user. The AWS side requires administrator access to AWS Secrets Manager and IAM.
Step 1: Create a Google Cloud project
-
Open the Google Cloud console
. -
From the project selector at the top of the page, choose New Project.
-
Enter a project name, and choose Create.
-
After the project is created, switch to it from the project selector.
Step 2: Enable the required APIs
-
In the Google Cloud console navigation menu, choose APIs & Services, then Library.
-
Search for and enable each of the following APIs:
Google Drive API
Google Drive Activity API
Admin SDK API
Step 3: Create the service account
-
In the navigation menu, choose APIs & Services, then Credentials.
-
Choose Create Credentials, then Service account.
-
Enter a name (for example,
bedrock-google-drive-connector) and an optional description, and choose Done. -
On the Credentials page, choose the service account you just created.
-
On the Details tab, copy the Unique ID. You use this in Step 5 to grant domain-wide delegation.
Step 4: Generate a private key
-
On the service account detail page, choose the Keys tab.
-
Choose Add Key, then Create new key.
-
Select JSON and choose Create. Your browser downloads a JSON file containing the service account's
client_emailandprivate_key. Store the file securely.
Note
If you receive an error stating that service account key creation is disabled
by an organization policy, you must override the
iam.disableServiceAccountKeyCreation constraint for your project.
For details, see Restricting service account usage
Step 5: Configure domain-wide delegation
Domain-wide delegation lets the service account act on behalf of users in your Google Workspace.
-
Sign in to the Google Workspace Admin Console
as a Google Workspace administrator. -
In the navigation pane, choose Security, Access and data control, API controls.
-
Choose Manage Domain Wide Delegation, then Add new.
-
For Client ID, enter the service account's Unique ID from Step 3.
-
For OAuth scopes, enter the following comma-separated values:
https://www.googleapis.com/auth/drive.readonly, https://www.googleapis.com/auth/drive.metadata.readonly, https://www.googleapis.com/auth/admin.directory.user.readonly, https://www.googleapis.com/auth/admin.directory.group.readonly, https://www.googleapis.com/auth/cloud-platform, https://www.googleapis.com/auth/forms.body.readonly -
Choose Authorize.
Step 6: Create a delegated admin user
The service account impersonates a Google Workspace admin user when crawling content. We recommend creating a dedicated admin user for this purpose with the minimum required roles.
-
In the Google Workspace Admin Console, choose Directory, then Users.
-
Choose Add new user, enter a first name, last name, and primary email address, and choose Add new user.
-
From the user list, open the user you created.
-
Expand the Admin roles and privileges section, and assign the following roles:
Groups Reader
User Management Admin
Storage Admin
-
Choose Save. Record this user's email address; you store it in the secret as
adminAccountEmail.
Step 7: Create the Secrets Manager secret
Store the credentials in an AWS Secrets Manager secret with the following key-value pairs.
Copy clientEmail and privateKey from the JSON key file
you downloaded in Step 4 (use the client_email and
private_key values).
{ "adminAccountEmail": "admin@your-domain.com", "clientEmail": "your-service-account@your-project.iam.gserviceaccount.com", "privateKey": "your-private-key-from-the-json-key-file" }
Create the secret with the AWS Command Line Interface:
aws secretsmanager create-secret \ --namebedrock-google-drive-sa-creds\ --secret-string file://secret.json
Record the secret ARN from the response. You use it as the data source
secretArn.
Note
The privateKey value contains literal \n escape
sequences from the JSON key file. Keep them as-is when copying the value into
the secret.
Next steps
After you store the secret, create the data source with authType set
to SERVICE_ACCOUNT. See Connect a Google Drive data source. To filter query results by
user permissions, see Document-level access controls.