Overview
Use the Gmail integration after the shared GCP setup to ingest Google Workspace mailboxes for the domain you want Asymptote to track. The current Gmail integration enumerates Workspace users through the Admin SDK Directory API, runs an initial mailbox backfill, processes ongoing Gmail history notifications through Pub/Sub, normalizes mailbox data, and renews mailbox watches on a schedule.Before you start
- Run the shared GCP setup first with
./cloud-providers/gcp/scripts/init.sh. - Install Terraform
>= 1.9,gcloud,jq, andcurl. - Make sure you have a Google Workspace super admin who can grant domain-wide delegation in the Google Workspace Admin Console.
- Make sure the Workspace domain and admin subject email you plan to use belong to the Google Workspace tenant you want to ingest.
- If you have more than one generated GCP install under
generated/gcp/, decide whichinstall-state.jsonyou want to use and pass it with--install-state PATH. - Use a GCP identity that can create Gmail integration resources and deploy the Gmail workloads.
The Gmail installer prints a delegated service account OAuth client ID. A Google Workspace super admin must add that client ID in the Admin Console before the installer can validate mailbox access and start the backfill.
Fill install.yaml
The Gmail installer reads cloud-providers/gcp/scripts/integrations/gmail/install.yaml by default.
Gmail inherits the hosting mode, project ID, region, and other shared values from the base install-state.json. You do not set those again here.
Fill in these fields:
gmail.workspace_domain: required. Use the Google Workspace domain whose mailboxes you want to ingest.gmail.admin_subject_email: required. Use a Google Workspace admin email in that same tenant. The installer uses this subject for Admin SDK Directory listing and delegation validation.gmail.included_labels: optional. If you leave it blank, the installer defaults toINBOX,SENT, andDRAFT. In v1, onlyINBOX,SENT, andDRAFTare supported.gmail.mailbox_quota_units_per_minute: optional. Defaults to12000.gmail.api_max_retries: optional. Defaults to5.gmail.api_initial_backoff_seconds: optional. Defaults to1.0.gmail.api_max_backoff_seconds: optional. Defaults to30.0.gmail.draft_refresh_interval_seconds: optional. Defaults to300.gmail.ingest_max_instances: optional. Defaults to10.gmail.normalization.filters.max_event_age_days: optional. Use0or leave it unset for no age filter.gmail.watch_renewal_schedule: optional. Defaults to0 4 * * *.gmail.watch_renewal_time_zone: optional. Defaults toEtc/UTC.
Hosting modes
Gmail uses the same Google Workspace domain-wide delegation flow in both base modes.self-hosting: the Gmail installer creates the Gmail-specific infrastructure in your project and then waits for a Workspace super admin to authorize the delegated service account client ID.cloud-hosting: the shared GCP foundation still comes from your basemode, but the Gmail integration itself uses the same delegated service account grant flow asself-hosting.
Run the installer
Update `cloud-providers/gcp/scripts/integrations/gmail/install.yaml`
Fill in the Workspace domain, admin subject email, labels, and any quota, retry, normalization, or watch-renewal settings you want to override.
Add the delegated OAuth client ID in Google Workspace Admin Console
After Terraform finishes, the installer prints the Gmail delegated service account email and its OAuth client ID, and writes the same instructions to:Sign in to Google Workspace Admin Console as a super admin, then open:Add the printed client ID and authorize these scopes:
Update the integration later
If Gmail is already connected and you want to change the synced labels, admin subject email, throttling behavior, or watch-renewal settings, update the existing Gmail integration instead of rerunning the base GCP setup.Update the Gmail settings
Edit
cloud-providers/gcp/scripts/integrations/gmail/install.yaml and keep the full set of labels you want synced in gmail.included_labels, along with any updated workspace_domain, admin_subject_email, quota, retry, normalization, or watch-renewal values.Confirm the Workspace admin grant still matches the generated client ID
If you rerun against the same base install, the delegated client ID should stay the same. If you target a different base install or project and the installer prints a new client ID, add that new client ID in Google Workspace Admin Console before resuming.
Troubleshooting
- If the installer cannot find the base setup you want, pass
--install-state /path/to/install-state.json. - If the installer says
gmail.workspace_domain is required, fill ingmail.workspace_domain. - If the installer says
gmail.admin_subject_email is required, fill ingmail.admin_subject_emailwith a Google Workspace admin email in the same tenant. - If the installer says
gmail.included_labels must contain at least one supported label, add at least one label togmail.included_labels. In v1, the supported values are onlyINBOX,SENT, andDRAFT. - If the installer fails while validating Workspace delegation after you added the client ID, wait a few minutes for the Google Workspace Admin Console grant to propagate, then rerun with
--resume-after-admin-grant. - If Terraform apply fails while creating IAM bindings for Gmail-specific principals, check whether the legacy domain-restricted-sharing constraint
iam.allowedPolicyMemberDomainsis blocking Google-managed principals such asgmail-api-push@system.gserviceaccount.com.

