Aurora Databases API

Create and list Aurora (PostgreSQL) databases per client with region selection (e.g. ca-central-1). Each resource is tracked in the client_resources table for usage and capacity.

For the underlying infrastructure (CloudFormation, Data API), see Aurora Serverless Architecture.


Overview

  • Base path: /api/aurora/databases
  • Methods: GET (list / get one), POST (create)
  • Region: Required on create; optional filter on list
  • Tracking: All resources stored in client_resources (company, region, status, capacity)

The API creates logical databases inside an existing Aurora cluster via the RDS Data API. You choose the AWS region (e.g. ca-central-1) so each client's database lives in the correct region. Resources are recorded in your main app DB (Neon) for capacity and usage tracking.


Endpoints

MethodPathDescription
GET/api/aurora/databases?companyId=...&region=...List databases for a company (optional region filter)
POST/api/aurora/databasesCreate a database in a given region and register it for the company
GET/api/aurora/databases/[resourceId]Get one resource by id

List databases

GET /api/aurora/databases

Query

  • companyId (required): Company id (must exist in companies).
  • region (optional): Filter by AWS region (e.g. ca-central-1).
GET https://apis.audla.ca/api/aurora/databases?companyId=clxx...&region=ca-central-1
{
  "databases": [
    {
      "id": "clxx...",
      "companyId": "clxx...",
      "resourceType": "aurora_database",
      "name": "emulsion_db",
      "region": "ca-central-1",
      "status": "active",
      "externalId": "emulsion_db",
      "clusterArn": "arn:aws:rds:ca-central-1:...",
      "maxCapacityAcu": 4,
      "currentUsageAcu": null,
      "storageBytes": null,
      "metadata": {},
      "createdAt": "2025-02-04T...",
      "updatedAt": "2025-02-04T..."
    }
  ]
}

Create database

POST /api/aurora/databases
Content-Type: application/json

Body

FieldTypeRequiredDescription
companyIdstringYesCompany id (must exist in companies).
namestringYesDatabase name. Normalized to lowercase, spaces → _. Letters, numbers, underscore only.
regionstringYesAWS region where the database will live (e.g. ca-central-1).
maxCapacityAcunumberNoMax Aurora capacity units (for tracking).

Example (e.g. for client Émulsion in ca-central-1)

{
  "companyId": "clxx...",
  "name": "emulsion_db",
  "region": "ca-central-1",
  "maxCapacityAcu": 4
}

Response (201)

{
  "success": true,
  "resource": {
    "id": "clxx...",
    "name": "emulsion_db",
    "region": "ca-central-1",
    "status": "active"
  },
  "note": "Database created in ca-central-1 and recorded."
}

If no Aurora cluster/secret is configured for the requested region, the API still creates a record in client_resources with status: "pending".


Get one resource

GET /api/aurora/databases/[resourceId]

Returns the full row from client_resources (id, companyId, resourceType, name, region, status, externalId, clusterArn, maxCapacityAcu, currentUsageAcu, storageBytes, metadata, createdAt, updatedAt).

404{ "error": "Resource not found" } if resourceId does not exist.


Environment variables

For creating databases in Aurora (Data API), set per region. Region suffix: hyphens → underscores, uppercase (e.g. ca-central-1CA_CENTRAL_1).

RegionCluster ARNSecret ARN
ca-central-1AURORA_CLUSTER_ARN_CA_CENTRAL_1AURORA_SECRET_ARN_CA_CENTRAL_1

Fallback: AURORA_CLUSTER_ARN and AURORA_SECRET_ARN if per-region vars are not set.

Other

  • AURORA_DEFAULT_DATABASE (optional): Database used to run CREATE DATABASE (default: postgres).
  • AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY: For RDS Data API (region is taken from the request).

Tracking: All endpoints require POSTGRES_URL (Neon/main app DB) where client_resources lives.


Table: client_resources

Resources (e.g. Aurora databases) per company for usage and capacity:

ColumnTypeDescription
idtext (PK)CUID.
companyIdtext (FK → companies)Owner company.
resource_typetexte.g. aurora_database.
nametextLogical name (e.g. DB name).
regiontextAWS region (e.g. ca-central-1).
statustextpending, active, suspended, deleted.
external_idtextExternal id (e.g. DB name in Aurora).
cluster_arntextAurora cluster ARN.
max_capacity_acuintegerMax ACU (tracking).
current_usage_acuintegerCurrent ACU snapshot.
storage_bytesintegerStorage (optional).
metadatajsonbExtra fields.
createdAt, updatedAttimestampAudit.

Apply migrations with npm run db:push or run the SQL in drizzle/migrations/ for the client_resources table.

Was this page helpful?