BigQuery: Read-Only Service Account
Create a minimal-privilege GCP service account for FreshGuard.
This guide covers creating a GCP service account with the minimum permissions FreshGuard needs to monitor your BigQuery tables.
Option 1: GCP Console
Create the Service Account
- Open the GCP Console and select your project.
- Navigate to IAM & Admin > Service Accounts.
- Click Create Service Account.
- Name it
freshguard-reader(or similar) and give it a description like “Read-only access for FreshGuard monitoring”. - Click Create and Continue.
Assign Roles
On the “Grant this service account access to project” step, add two roles:
- BigQuery Data Viewer (
roles/bigquery.dataViewer) — Allows reading table data and metadata. - BigQuery Job User (
roles/bigquery.jobUser) — Allows running queries (required for freshness checks).
Click Continue, then Done.
Warning
Do not grant BigQuery Data Editor, BigQuery Admin, or any write-level roles. FreshGuard only needs read access.
Create a JSON Key
- Click on the service account you just created.
- Go to the Keys tab.
- Click Add Key > Create New Key.
- Select JSON format.
- Click Create — the key file will download automatically.
Store this file securely. You’ll paste its contents into FreshGuard when connecting BigQuery.
Option 2: gcloud CLI
If you prefer the command line:
# Set your projectgcloud config set project YOUR_PROJECT_ID
# Create the service accountgcloud iam service-accounts create freshguard-reader \ --display-name="FreshGuard Reader" \ --description="Read-only access for FreshGuard monitoring"
# Grant BigQuery Data Viewergcloud projects add-iam-policy-binding YOUR_PROJECT_ID \ --member="serviceAccount:freshguard-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com" \ --role="roles/bigquery.dataViewer"
# Grant BigQuery Job Usergcloud projects add-iam-policy-binding YOUR_PROJECT_ID \ --member="serviceAccount:freshguard-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com" \ --role="roles/bigquery.jobUser"
# Create and download the JSON keygcloud iam service-accounts keys create freshguard-key.json \ --iam-account=freshguard-reader@YOUR_PROJECT_ID.iam.gserviceaccount.comReplace YOUR_PROJECT_ID with your actual GCP project ID.
Dataset-Level Permissions
If you want to restrict FreshGuard to specific datasets instead of the entire project, grant roles at the dataset level:
- Open BigQuery in the GCP Console.
- Click on the dataset you want to monitor.
- Click Sharing > Permissions.
- Add the service account email and assign BigQuery Data Viewer.
Repeat for each dataset. Note that BigQuery Job User still needs to be granted at the project level — it cannot be scoped to a dataset.
Tip
After creating the key file, paste its full contents into the “Service Account JSON” field when connecting BigQuery in FreshGuard.