Skip to content

Cluster

Source: src/AWS/DocDBElastic/Cluster.ts

An Amazon DocumentDB elastic cluster — a MongoDB-compatible, sharded document database that scales workloads to millions of reads/writes per second without managing instances.

Elastic clusters take roughly 8-10 minutes to provision and bill per shard-vCPU-hour while they exist. They are reachable only from inside a VPC. Destroy clusters you are not using.

Minimal Elastic Cluster

const cluster = yield* Cluster("Documents", {
adminUserName: "admin",
adminUserPassword: Redacted.make("super-secret-password"),
shardCapacity: 2,
shardCount: 1,
});

Cluster Pinned to Specific Subnets

const cluster = yield* Cluster("Documents", {
adminUserName: "admin",
adminUserPassword: Redacted.make("super-secret-password"),
shardCapacity: 2,
shardCount: 1,
subnetIds: [subnetA.subnetId, subnetB.subnetId],
vpcSecurityGroupIds: [securityGroup.securityGroupId],
backupRetentionPeriod: "1 day",
});