Databases

PostgreSQL, MySQL, MongoDB or ClickHouse with a managed password.

Overview

A database keeps your app’s data on disk: PostgreSQL, MySQL, MongoDB or ClickHouse. EnclaveStack creates it with a strong owner password, kept as a secret your apps can use.

It answers to a private name in its network, and backs up to a bucket on a schedule when you add a backup.

When to use it

  • Users, orders, posts — data that must not be lost (PostgreSQL, MySQL).
  • Documents with a flexible shape (MongoDB).
  • Analytics over many rows (ClickHouse).

How it works

PostgreSQL 16 or 17
postgres:<version>-alpine, port 5432, health check pg_isready, 512 MiB by default.
MySQL 8.4
mysql:8.4, port 3306, 1024 MiB by default.
MongoDB 7.0 or 8.0
mongo:<version>, port 27017, 1024 MiB by default.
ClickHouse 25.8 or 26.3
clickhouse-server, HTTP 8123 and native 9000, 2048 MiB by default.
Data volume
The data directory is an engine volume that survives restarts, upgrades and moves.

Each database is one container from a pinned image, with its data on a volume and its owner password in a managed secret (<name>-password). Apps reach it as <name>.database.internal.

Backups take a logical dump with the engine’s own tool — pg_dump for PostgreSQL — and stream it into a bucket while computing its checksum.

Architecture

Databases architectureApps reach the database by name with the password from its secret; backups stream to a bucket.SQLdumpuploadYour appDB_PASSWORD from secretPostgreSQLorders.database.internal:5432Data volumeBackuppg_dump, streamedBucketkept copies
Apps reach the database by name with the password from its secret; backups stream to a bucket.
  • Your app to PostgreSQL: SQL
  • PostgreSQL to Data volume
  • PostgreSQL to Backup: dump
  • Backup to Bucket: upload

Flows

Creating a database

  1. EnclaveStack generates the owner password and stores it encrypted as <name>-password.
  2. It creates the data volume and starts the engine’s container.
  3. It waits for the engine’s health check, then marks it Ready with its address.

Connecting from an app

  1. Give the app the host <name>.database.internal and the password from the secret.
  2. The app connects inside the network; nothing is exposed to the internet.

Set it up

In the console

  1. Open Databases and choose New database.
  2. Name it and choose the engine and version.
  3. Choose Create; its page shows the address and the password’s secret.

With the CLI

enclave db create orders --wait

With OpenTofu

OpenTofu configuration
resource "enclave_database" "orders" {
  name    = "orders"
  engine  = "postgres"
  version = "16"
}

Settings reference

Every setting and output of the OpenTofu resource; the console and the CLI use the same names in their own words. Generated from platform 4d30582.

enclave_database
NameTypeUseWhat it does
nametextrequiredName of the database: 3–40 lowercase letters, digits or hyphens, starting with a letter. Changing it replaces the database.
enginetextoptionalpostgres (default), mysql, mongodb or clickhouse. Changing it replaces the database (and its data).
machinetextoptionalThe machine to run on (default: EnclaveStack chooses, and this reads back its choice). Changing it moves the resource, with its data, in place; apply waits for the move.
machine_labelsmap of textoptionalLabels the machine must have, when machine isn't set (key=value, all must match).
networktextoptionalNetwork to place it in (default: the default network). Changes in place.
projecttextoptionalThe project to create it in. Defaults to the provider's project (ENCLAVE_PROJECT, else default). Changing it replaces the resource.
subnettextoptionalSubnet of the network (default: its first).
versiontextoptionalThe engine's version (default the engine's own: postgres 16, mysql 8.4, mongodb 7.0, clickhouse 26.3). Changing it replaces the database (and its data).
database_nametextoutputDatabase name.
engine_port_nativenumberoutputClickHouse's native-protocol port on this machine (port is its HTTP interface).
hosttextoutputHost to connect to from this machine (none in a network without internet).
idtextoutputResource ID.
internal_hosttextoutputHost apps use on the EnclaveStack network.
internal_portnumberoutputPort apps use on the EnclaveStack network.
password_secrettextoutputName of the managed secret holding the owner password.
portnumberoutputPort to connect to from this machine (none in a network without internet).
private_dnstextoutputName it answers to inside its network: <name>.database.internal.
private_iptextoutputAddress in its network.
usernametextoutputOwner user name.

Limits and security

Good to know

  • The engine and version can’t change after creation; create a new database and restore a backup into it.
  • Data lives on this machine; add a backup to keep a copy elsewhere.

Security

  • The password is generated, stored encrypted and never shown in logs or events.
  • Deleting asks you to type the name first; the data goes with it.