Overview
A managed PostgreSQL database with pgvector, private on every cloud.
alien.Postgres is a managed relational database. Declare it in your alien.ts and Alien provisions the right PostgreSQL for the target platform — with pgvector available out of the box and no public IP.
Platform Mapping
| Platform | Backing Service | Provisioned by |
|---|---|---|
| AWS | Aurora Serverless v2 (PostgreSQL) | Alien |
| GCP | Cloud SQL for PostgreSQL (Enterprise) | Alien |
| Azure | Azure Database for PostgreSQL — Flexible Server | Alien |
| Kubernetes / On-Prem | External (operator-provided) | Cluster operator |
| Local | Embedded native PostgreSQL process | Alien |
On Kubernetes / on-prem, Postgres is not provisioned by Alien — the cluster operator provides the database (see Behavior).
When to Use
Use Postgres when your app needs a relational database: transactions, joins, SQL, and — via pgvector — embeddings and similarity search for RAG and semantic search.
Reach for a different resource when Postgres isn't the fit: large files and blobs belong in Storage, and simple key lookups with TTL in KV.
The database is reachable only by same-stack workloads (see Behavior). It is not an internet-facing database.
Stack Definition
const db = new alien.Postgres("db").build()
// Sized explicitly
const analytics = new alien.Postgres("analytics")
.version("17")
.cpu("2")
.memory("8Gi")
.storage("100Gi")
.highAvailability()
.build()| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | — | Resource identifier. On Local it's also the database name; on the managed clouds the database is named alien (read it from the binding's database field). |
version | string | "17" | Major engine version: "15", "16", or "17". |
cpu | string | smallest tier | Requested vCPUs, e.g. "0.5", "2". Helps size the GCP/Azure tier; not used on AWS. |
memory | string | smallest tier | Requested memory, e.g. "1Gi", "8Gi". Sizes AWS, and helps size the GCP/Azure tier. |
storage | string | "20Gi" | Allocated storage. Grow-only. |
highAvailability | boolean | false | Multi-AZ / regional / zone-redundant HA. |
cpu and memory are sizing hints: GCP and Azure pick the smallest tier that satisfies both; AWS sizes from memory (Aurora Serverless v2 is ACU-based). See Behavior for the per-cloud detail.
pgvector Out of the Box
pgvector is available on every platform Alien provisions. Run the one standard line in your migrations:
CREATE EXTENSION IF NOT EXISTS vector;pg_trgm, uuid-ossp, and pgcrypto are available too. See Behavior for the shipped version and index types.
Connecting
The binding exposes connection details; your app connects with its own driver or ORM.
import { getPostgresConnection } from "@alienplatform/sdk"
const conn = await getPostgresConnection("db")
// conn.host, conn.port, conn.database, conn.username, conn.password, conn.ssllet db = ctx.bindings().load_postgres("db").await?;
let conn_str = db.connection_string();See the API Reference for the full connection object and driver-specific notes.