GCP Per-Bucket Credentials
By default, all GCS operations use a single set of credentials - the service account
referenced by the GOOGLE_APPLICATION_CREDENTIALS environment variable (or the ambient
credentials on GCE/GKE). This is sufficient when all GCS buckets belong to the same
GCP project and service account.
extra.gcp.application_creds lifts that restriction: it lets each bucket in AIS carry
its own GCP service-account JSON path, completely overriding the global default for that
bucket’s operations.
Table of Contents
- The
extra.gcpsection - Setting per-bucket credentials
- Credentials file format
- Registering a bucket that the default credentials cannot reach
- Multiple buckets, multiple GCP projects
- Startup behavior
- Clearing per-bucket credentials
- See also
The extra.gcp section
To inspect the GCP-specific knobs for a bucket:
or in JSON to see all supported fields regardless of whether they are set:
Note on
-: a dash in--jsonoutput means the field is supported but currently unset (no value configured). It is not a valid value to assign.
Setting per-bucket credentials
From this point on, every operation on gs://abc - GET, PUT, HEAD, LIST - will
authenticate using the service account in /mnt/vault/sa-team-b.json instead of the
cluster-wide default.
The path must be absolute and clean (no .. components). AIS validates this when the
property is set and returns an error if the path is relative or malformed.
The file must also be outside every AIS data mountpath.
A target rejects paths inside its own mountpaths to prevent a stored object from serving as a credential. When targets share a filesystem (for example, the local playground or a shared volume), a user can store an object through one target and set this property to the path of that object. Another target then reads the object as credentials. Do not share a filesystem between targets in production, and restrict who can change bucket properties.
Example: validate per-bucket credentials on first access
Create bucket with non-default creds bypassing lookup:
On the other hand, if the credentials file is invalid or missing:
Credentials file format
The value is a file path to a GCP credentials JSON file.
The type field must be either service_account or external_account (Workload Identity Federation).
Service-account key:
External account (Workload Identity Federation):
Only credential_source.file (optionally with format) is accepted.
Other sources such as url or executable are rejected.
Each AIS target must have access to the specified token file locally.
For both types, project_id is optional.
AIS reads it from the file when present; otherwise the default session uses the GOOGLE_CLOUD_PROJECT environment variable.
The project ID is needed only to list buckets.
Listing fails with “empty project ID” when neither is set.
In Kubernetes, service-account keys are typically mounted as files via a Secret volume:
which makes /mnt/vault/sa/key.json a normal readable file from AIS’s perspective.
Registering a bucket that the default credentials cannot reach
If the cluster’s default service account has no access to the bucket, use --skip-lookup
to bypass the initial HEAD check:
Then verify access:
--skip-lookupregisters the bucket in BMD without verifying reachability. Use it only when you know the bucket exists and the per-bucket credentials are correct.
Multiple buckets, multiple GCP projects
extra.gcp.application_creds is per-bucket, so you can mix projects freely:
gs://#proj-a/dataset and gs://#proj-b/dataset are distinct BMD entries with separate
on-disk paths, separate session caches, and independent credentials. The namespace
component (e.g., #proj-a, #proj-b) disambiguates same-name buckets across projects.
AIS caches the GCP client session keyed by credentials file path, so the overhead of
creating a new *storage.Client is paid once per unique credentials file across the
lifetime of the target process.
Startup behavior
AIS initializes the default GCP session lazily - on first use, not at target startup.
A missing or invalid GOOGLE_APPLICATION_CREDENTIALS will not prevent the target from
starting
An error will occur only when accessing a bucket that requires the default (missing or invalid) credentials.
Per-bucket sessions (extra.gcp.application_creds) are resolved the same way: on
demand, then cached.
Clearing per-bucket credentials
To revert a bucket to the cluster-wide default: