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
| Method | Path | Description |
|---|---|---|
| GET | /api/aurora/databases?companyId=...®ion=... | List databases for a company (optional region filter) |
| POST | /api/aurora/databases | Create 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 incompanies).region(optional): Filter by AWS region (e.g.ca-central-1).
GET https://apis.audla.ca/api/aurora/databases?companyId=clxx...®ion=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
| Field | Type | Required | Description |
|---|---|---|---|
companyId | string | Yes | Company id (must exist in companies). |
name | string | Yes | Database name. Normalized to lowercase, spaces → _. Letters, numbers, underscore only. |
region | string | Yes | AWS region where the database will live (e.g. ca-central-1). |
maxCapacityAcu | number | No | Max 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-1 → CA_CENTRAL_1).
| Region | Cluster ARN | Secret ARN |
|---|---|---|
| ca-central-1 | AURORA_CLUSTER_ARN_CA_CENTRAL_1 | AURORA_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 runCREATE 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:
| Column | Type | Description |
|---|---|---|
id | text (PK) | CUID. |
companyId | text (FK → companies) | Owner company. |
resource_type | text | e.g. aurora_database. |
name | text | Logical name (e.g. DB name). |
region | text | AWS region (e.g. ca-central-1). |
status | text | pending, active, suspended, deleted. |
external_id | text | External id (e.g. DB name in Aurora). |
cluster_arn | text | Aurora cluster ARN. |
max_capacity_acu | integer | Max ACU (tracking). |
current_usage_acu | integer | Current ACU snapshot. |
storage_bytes | integer | Storage (optional). |
metadata | jsonb | Extra fields. |
createdAt, updatedAt | timestamp | Audit. |
Apply migrations with npm run db:push or run the SQL in drizzle/migrations/ for the client_resources table.