anomalyco/sst · error · VisibleError

Database instance not found in cluster ${cluster.id}

Error message

Database instance not found in cluster ${cluster.id}

What it means

When you reference an existing Aurora RDS component via `Aurora.get(...).ref` (through the `reference` helper), SST fetches the cluster's instance identifiers and picks the first one. If the cluster reports zero instances, SST cannot build a connection target and throws with the cluster's Pulumi resource ID.

Source

Thrown at platform/src/components/aws/aurora.ts:741

      });

      const instance = rds.ClusterInstance.get(
        `${name}Instance`,
        rds
          .getInstancesOutput(
            {
              filters: [
                {
                  name: "db-cluster-id",
                  values: [cluster.id],
                },
              ],
            },
            { parent: self },
          )
          .instanceIdentifiers.apply((ids) => {
            if (!ids.length) {
              throw new VisibleError(
                `Database instance not found in cluster ${cluster.id}`,
              );
            }
            return ids[0];
          }),
        undefined,
        { parent: self },
      );

      const secretId = cluster.tagsAll
        .apply((tags) => tags?.["sst:ref:password"])
        .apply((passwordTag) => {
          if (!passwordTag)
            throw new VisibleError(
              `Failed to get password for Postgres ${name}.`,
            );
          return passwordTag;
        });

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Verify the referenced cluster exists and has at least one running instance: `aws rds describe-db-instances --db-cluster-identifier <cluster>`
  2. Correct the `cluster.id`/ref in sst.config.ts to point at the intended Aurora component
  3. Re-run `sst deploy` so the cluster finishes provisioning before referencing it (check for failed instance creation in the AWS console)

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

null

Try / catch

try {
  const db = sst.aws.Aurora.get("DbRef", { clusterArn, databaseName, password });
  const conn = db.ref;
} catch (e) {
  if (String(e).includes("Database instance not found")) {
    throw new Error("Referenced Aurora cluster has no instances — check cluster id and that the cluster is running: aws rds describe-db-clusters");
  }
  throw e;
}

Prevention

When it happens

Trigger: Referencing an Aurora cluster whose all instances were deleted (or the cluster is being created and instances aren't ready, or the referenced `cluster.id` points to a non-existent/empty cluster).

Common situations: Pointing `ref` at the wrong cluster (typo in cluster ARN/id or wrong stage), an Aurora Serverless v2 cluster whose writer instance failed to provision, or a race where the ref is evaluated before instances exist.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/1b71dbf673924ecc. Report an issue: GitHub.