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. The binding shape differs by platform — see the API Reference for the full shape per platform. It is the source of truth; the quick start below only covers Local and External, where the password arrives inline.

For Local and External Postgres, parse the ALIEN_DB_BINDING environment variable (ALIEN_<NAME>_BINDING, uppercased, hyphens to underscores) and hand the fields to your driver:

import { Client } from "pg"

const binding = JSON.parse(process.env.ALIEN_DB_BINDING!)
// local-postgres / external — { service, host, port, database, username, password }

const client = new Client({
  host: binding.host,
  port: binding.port,
  database: binding.database,
  user: binding.username,
  password: binding.password,
})

On AWS, GCP, and Azure the binding carries a secret locator instead of an inline password — see API Reference for the per-cloud fields and how to resolve them.

See the API Reference for the full binding shape per platform, TLS settings, and driver-specific notes.

On this page