> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Cloud plugin

> Pub/Sub topics, subscriptions and messages; IAM service accounts, keys, roles and workload identity; projects, folders, organizations, tags and IAM policies; turning APIs on and off; Cloud Run services, revisions and jobs; Cloud Functions; Cloud Build; Artifact Registry; Cloud Storage buckets and objects; Cloud Logging; Cloud Monitoring; Secret Manager; Cloud Scheduler; Cloud Tasks; Cloud SQL; Compute Engine VMs, disks, images, networks and firewalls; and Cloud Billing and budgets (1058 operations).

Use **Google Cloud** through Corsair: one client, typed API calls.

Connect in one of two ways. **Google sign-in** (OAuth, scope
`cloud-platform`): calls run with the signed-in person's own access to
their projects. **Service account key**: the whole JSON key file (Cloud
console > IAM & Admin > Service accounts > Keys > Add key > JSON), stored as
the key; the plugin signs a JWT with it and trades it at
oauth2.googleapis.com for an access token, cached until a minute before it
expires. Give the service account only the roles the calls need. A ready
access token (`ya29...`) works as the key too, until it expires.

* **Resource names.** Most APIs address things by their full name:
  `projects/<project>/topics/orders`,
  `projects/<project>/locations/us-central1/services/api`,
  `projects/<project>/secrets/stripe-key/versions/latest`. Pass them whole in
  `name`, `parent`, `topic` or `resource`; slashes are kept. Cloud Storage,
  Compute Engine and Cloud SQL take the parts instead (`bucket` + `object`,
  `project` + `zone` + `instance`).
* **Groups.** `pubsub.*`, `iam.*` (service accounts and their keys, roles,
  workload identity pools for keyless CI sign-in) and `iamCredentials.*`
  (short-lived tokens for a service account), `resourceManager.*` (projects,
  folders, organizations, tags and their IAM policies), `serviceUsage.*`
  (turning APIs on and off), `run.*`, `functions.*`, `build.*`,
  `artifactRegistry.*`, `storage.*` (`storage.objects.insert` with `file`
  uploads, `storage.objects.download` returns the bytes), `logging.*`,
  `monitoring.*`, `secretManager.*`, `scheduler.*`, `tasks.*`, `sql.*`,
  `compute.*`, `billing.*` and `budgets.*`.
* **Turn the API on first.** A call to an API the project hasn't enabled
  fails with 403 "has not been used in project ... or it is disabled":
  run `serviceUsage.services.enable` with
  `projects/<project>/services/<api>.googleapis.com`, then retry after a
  minute.
* **Long-running operations.** Creates and deletes on Cloud Run, Functions,
  Service Usage, Cloud SQL and Compute return an operation; read it with the
  same API's `operations.get` (Compute: `zoneOperations.get`,
  `regionOperations.get`, `globalOperations.get`). Most APIs mark a finished
  operation with `done: true` (check `error` too); Compute Engine and Cloud
  SQL operations use `status: "DONE"` instead.
* **IAM policies.** `setIamPolicy` replaces the whole policy: read it with
  `getIamPolicy`, add the binding, and send it back with its `etag`, so a
  change made in between is refused instead of overwritten.
* **Quota project.** With Google sign-in, Service Usage, Billing Budgets and
  a few other APIs ask which project to bill the quota to: set
  `quotaProject` in the plugin options.
* **Lists** page with `pageSize` and `pageToken` (Cloud Storage, Compute
  and Cloud SQL use `maxResults`); pass the response's `nextPageToken` for the
  next page.
* **Risk.** Reads (GETs and the POSTs that only read, such as
  `getIamPolicy`, `testIamPermissions`, searches and `logging.entries.list`)
  are `read`. Deletes and destroys, replacing an IAM policy, turning an API or
  a service account off, stopping or resetting VMs and databases, changing a
  project's billing account, moving a project or billing account, publishing
  a Pub/Sub message or seeking a subscription, sending a verification code,
  running a job, build, trigger or task now, running SQL, minting credentials
  (service account keys, signed JWTs, access and ID tokens), committing a
  function upgrade and locking a bucket's retention policy are `destructive`;
  other writes are `write`.
* Not wrapped: Compute Engine's load balancing, VPN, interconnect, security
  policy and reservation APIs; Cloud Logging's folder, organization and
  billing-account copies of its config API (the top-level calls take any
  parent); workforce identity pools; Cloud Storage push channels; webhook
  receivers; and streaming calls (`logging.entries.tail`). Other Google
  Cloud APIs (BigQuery, Firebase, Vision) have their own plugins.

**What you get:**

* 1058 typed API operations

## Setup

**1. Install**

```bash npm theme={null}
npm install corsair @corsair-dev/googlecloud better-sqlite3
npm install --save-dev @types/better-sqlite3
```

```bash yarn theme={null}
yarn add corsair @corsair-dev/googlecloud better-sqlite3
yarn add --dev @types/better-sqlite3
```

```bash pnpm theme={null}
pnpm install corsair @corsair-dev/googlecloud better-sqlite3
pnpm install --save-dev @types/better-sqlite3
```

```bash bun theme={null}
bun add corsair @corsair-dev/googlecloud better-sqlite3
bun add --dev @types/better-sqlite3
```

**2. Add the plugin**

```ts corsair.ts theme={null}
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { googlecloud } from '@corsair-dev/googlecloud';

export const corsair = createCorsair({
	plugins: [
		googlecloud(),
	],
	database: new Database('corsair.db'),
	kek: process.env.CORSAIR_KEK!,
	multiTenancy: true,
	hub: {
		projectApiKey: process.env.CORSAIR_API_KEY!,
		signingSecret: process.env.CORSAIR_SIGNING_SECRET!,
	},
});
```

With `multiTenancy: true`, scope calls with `corsair.withTenant(id)`. See [Quick start](https://docs.corsair.dev/quick-start.md) for KEK + Hub keys, and [Multi-tenancy](https://docs.corsair.dev/concepts/multi-tenancy.md) for account isolation.

**3. Choose authentication**

> [tab] OAuth 2.0 (Recommended)
>
> Open [hub.corsair.dev](https://hub.corsair.dev/dashboard), navigate to your project, and enter the **client ID** and **client secret** from your Google Cloud OAuth app.
>
> ```ts theme={null}
> googlecloud()
> ```
>
> More: [OAuth 2.0](https://docs.corsair.dev/concepts/oauth)

> [tab] API Key
>
> Store the Google Cloud API key before the first call: `pnpm corsair setup --plugin=googlecloud --tenant=acme api_key=<your-key>` (leave out `--tenant` without `multiTenancy`), or pass it as `key` in the plugin options. With Hub, each tenant enters their own key on the connect page. See [API key auth](https://docs.corsair.dev/concepts/api-key).
>
> ```ts theme={null}
> googlecloud({
> 	authType: 'api_key',
> })
> ```
>
> More: [API Key](https://docs.corsair.dev/concepts/api-key)

**4. Connect a tenant**

Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see [Connect / OAuth](https://docs.corsair.dev/management/connect).

```ts theme={null}
const { connectUrl } = await corsair.manage.connect.createLink({
	plugin: 'googlecloud',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**Read recent errors from Cloud Logging**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.googlecloud.api.logging.entries.list({
	resourceNames: ['projects/demo-project'],
	filter: 'timestamp>="2026-12-02T00:00:00Z" AND severity>=ERROR AND resource.type="cloud_run_revision"',
	orderBy: 'timestamp desc',
	pageSize: 50,
});
```

**Publish a Pub/Sub message**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.googlecloud.api.pubsub.topics.publish({
	topic: 'projects/demo-project/topics/orders',
	messages: [{
		data: 'eyJvcmRlciI6IDQyfQ==',
		attributes: { source: 'corsair' },
	}],
});
```

See the full list on the [API](https://docs.corsair.dev/plugins/googlecloud/api.md) page.

## What's next

> [card] [API reference](https://docs.corsair.dev/plugins/googlecloud/api.md)
>
> Every `googlecloud.api.*` operation with input and output types.

> [card] [Connect / OAuth](https://docs.corsair.dev/management/connect)
>
> createLink, Hub delivery, and tenant connect flows.

> [card] [Use with agents](https://docs.corsair.dev/mcp-adapters/mcp-adapters)
>
> Expose this plugin's operations as MCP tools.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.