Skip to content

GCP.AlloyDB reference

Source: src/GCP/AlloyDB/Backup.ts

An on-demand AlloyDB backup of a cluster.

Changing backupId, location, clusterName, type, encryptionConfig, tags, or description replaces the backup. displayName, labels, and annotations update in place.

Creating a backup typically takes several minutes and is skipIf-gated in live tests behind GCP_TEST_ALLOYDB.

On-demand backup of a cluster

const cluster = yield* GCP.AlloyDB.Cluster("AppDb", {
pscConfig: { pscEnabled: true },
automatedBackupPolicy: { enabled: false },
continuousBackupConfig: { enabled: false },
});
const backup = yield* GCP.AlloyDB.Backup("Nightly", {
clusterName: cluster.name,
displayName: "nightly",
labels: { env: "prod" },
});

Explicit id and description

const backup = yield* GCP.AlloyDB.Backup("Nightly", {
clusterName: cluster.name,
backupId: "app-db-nightly",
displayName: "app-db-nightly",
description: "manual snapshot",
});

Source: src/GCP/AlloyDB/Cluster.ts

An AlloyDB for PostgreSQL cluster (regional storage layer).

Changing clusterId, location, network / networkConfig, encryptionConfig, clusterType, secondaryConfig, or pscConfig.pscEnabled replaces the cluster. A database version upgrade patches in place; a downgrade replaces.

Provisioning typically takes several minutes. Delete always sends force=true so child instances do not block teardown.

Generated name with Private Service Connect

const cluster = yield* GCP.AlloyDB.Cluster("AppDb", {
location: "us-central1",
pscConfig: { pscEnabled: true },
initialUser: { user: "postgres", password: "change-me" },
automatedBackupPolicy: { enabled: false },
continuousBackupConfig: { enabled: false },
});

Explicit id, default VPC, and labels

const cluster = yield* GCP.AlloyDB.Cluster("AppDb", {
clusterId: "app-db",
location: "us-central1",
network: "default",
displayName: "app-db",
labels: { env: "prod" },
initialUser: { user: "postgres", password: "change-me" },
});
const cluster = yield* GCP.AlloyDB.Cluster("AppDb", {
pscConfig: { pscEnabled: true },
automatedBackupPolicy: { enabled: false },
continuousBackupConfig: { enabled: false },
});

Source: src/GCP/AlloyDB/ClustersUser.ts

A database user on an AlloyDB cluster.

AlloyDB users have no labels field. list enumerates non-postgres users on alchemy-labeled clusters so pnpm nuke:gcp can find leaked rows without dropping the built-in superuser.

Changing cluster, location, userId, or userType replaces the user. password and databaseRoles update in place. Creating a built-in user requires a READY primary instance.

Built-in user on a cluster

const cluster = yield* GCP.AlloyDB.Cluster("AppDb", {
pscConfig: { pscEnabled: true },
initialUser: { user: "postgres", password: "change-me" },
});
const primary = yield* GCP.AlloyDB.Instance("Primary", {
cluster: cluster.name,
});
const appUser = yield* GCP.AlloyDB.ClustersUser("AppUser", {
cluster: primary.clusterName,
password: "change-me-too",
databaseRoles: ["alloydbsuperuser"],
});

Explicit id and IAM user

const iamUser = yield* GCP.AlloyDB.ClustersUser("Analyst", {
cluster: cluster.name,
userId: "analyst@example.com",
userType: "ALLOYDB_IAM_USER",
databaseRoles: ["pg_read_all_data"],
});

Source: src/GCP/AlloyDB/GetBackup.ts

Runtime binding for AlloyDB backups.get.

Bind this operation to a Backup in a Function/Action init phase. Provide GetBackupHttp.

const getBackup = yield* GCP.AlloyDB.GetBackup(backup);
const live = yield* getBackup();

Source: src/GCP/AlloyDB/GetBackupHttp.ts Kind: Layer · Provides: GCP.AlloyDB.GetBackup

HTTP implementation of GetBackup.

Source: src/GCP/AlloyDB/GetCluster.ts

Runtime binding for AlloyDB clusters.get.

Bind this operation to a Cluster in a Function/Action init phase. Provide GetClusterHttp.

const getCluster = yield* GCP.AlloyDB.GetCluster(cluster);
const live = yield* getCluster();

Source: src/GCP/AlloyDB/GetClusterHttp.ts Kind: Layer · Provides: GCP.AlloyDB.GetCluster

HTTP implementation of GetCluster.

Source: src/GCP/AlloyDB/GetConnectionInfo.ts

Runtime binding for AlloyDB instances.getConnectionInfo.

Bind this operation to an Instance in a Function/Action init phase. Provide GetConnectionInfoHttp.

const getConnectionInfo = yield* GCP.AlloyDB.GetConnectionInfo(primary);
const info = yield* getConnectionInfo();

Source: src/GCP/AlloyDB/GetConnectionInfoHttp.ts Kind: Layer · Provides: GCP.AlloyDB.GetConnectionInfo

HTTP implementation of GetConnectionInfo.

Source: src/GCP/AlloyDB/GetInstance.ts

Runtime binding for AlloyDB instances.get.

Bind this operation to an Instance in a Function/Action init phase. Provide GetInstanceHttp.

const getInstance = yield* GCP.AlloyDB.GetInstance(primary);
const live = yield* getInstance();

Source: src/GCP/AlloyDB/GetInstanceHttp.ts Kind: Layer · Provides: GCP.AlloyDB.GetInstance

HTTP implementation of GetInstance.

Source: src/GCP/AlloyDB/GetUser.ts

Runtime binding for AlloyDB users.get.

Bind this operation to a ClustersUser in a Function/Action init phase. Provide GetUserHttp.

const getUser = yield* GCP.AlloyDB.GetUser(appUser);
const live = yield* getUser();

Source: src/GCP/AlloyDB/GetUserHttp.ts Kind: Layer · Provides: GCP.AlloyDB.GetUser

HTTP implementation of GetUser.

Source: src/GCP/AlloyDB/Instance.ts

An AlloyDB instance (compute attached to a cluster).

Changing cluster, location, instanceId, or instanceType replaces the instance. Machine size, flags, labels, activation policy, and read-pool size update in place.

A cluster may exist without instances (EMPTY). Creating a PRIMARY instance typically takes several minutes.

Primary instance on a cluster

const cluster = yield* GCP.AlloyDB.Cluster("AppDb", {
pscConfig: { pscEnabled: true },
});
const primary = yield* GCP.AlloyDB.Instance("Primary", {
cluster: cluster.name,
instanceType: "PRIMARY",
machineConfig: { cpuCount: 2 },
});

Explicit id, display name, and labels

const primary = yield* GCP.AlloyDB.Instance("Primary", {
cluster: cluster.name,
instanceId: "app-db-primary",
displayName: "app-db-primary",
labels: { env: "prod" },
machineConfig: { cpuCount: 2 },
});
const pool = yield* GCP.AlloyDB.Instance("Reads", {
cluster: cluster.name,
instanceType: "READ_POOL",
readPoolConfig: { nodeCount: 2 },
machineConfig: { cpuCount: 2 },
});