Skip to content

DBCluster

Source: src/AWS/DocDB/DBCluster.ts

An Amazon DocumentDB (MongoDB-compatible) cluster.

DBCluster owns the writer and reader endpoints and cluster-wide networking; instances are added via DBInstance. It can bootstrap master credentials directly or let DocumentDB manage them in Secrets Manager. Provisioning a cluster (and its first instance) takes several minutes.

Mutable fields are reconciled in place against the observed cloud state; immutable fields (engine, dbSubnetGroupName, storageEncrypted, kmsKeyId, globalClusterIdentifier, availabilityZones, masterUsername) force a replacement.

const cluster = yield* DBCluster("Docs", {
dbSubnetGroupName: subnetGroup.dbSubnetGroupName,
vpcSecurityGroupIds: [sg.groupId],
masterUsername: "alchemy",
manageMasterUserPassword: true,
backupRetentionPeriod: "7 days",
deletionProtection: false,
});
const cluster = yield* DBCluster("Docs", {
dbSubnetGroupName: subnetGroup.dbSubnetGroupName,
masterUsername: "alchemy",
masterUserPassword: Redacted.make("supersecret"),
storageEncrypted: true,
enableCloudwatchLogsExports: ["audit", "profiler"],
});