Docs

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

PlatformBacking ServiceProvisioned by
AWSAurora Serverless v2 (PostgreSQL)Alien
GCPCloud SQL for PostgreSQL (Enterprise)Alien
AzureAzure Database for PostgreSQL — Flexible ServerAlien
Kubernetes / On-PremExternal (operator-provided)Cluster operator
LocalEmbedded native PostgreSQL processAlien

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()
ParameterTypeDefaultDescription
idstringResource 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).
versionstring"17"Major engine version: "15", "16", or "17".
cpustringsmallest tierRequested vCPUs, e.g. "0.5", "2". Helps size the GCP/Azure tier; not used on AWS.
memorystringsmallest tierRequested memory, e.g. "1Gi", "8Gi". Sizes AWS, and helps size the GCP/Azure tier.
storagestring"20Gi"Allocated storage. Grow-only.
highAvailabilitybooleanfalseMulti-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.ssl
let 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.

On this page