Skip to main content
The official Rivestack Terraform provider lets you manage clusters, databases, users, extensions, grants, and backups as code.

Installation

Add the provider to your Terraform configuration:
Requires Terraform >= 1.0.

Authentication

Get your API key from the Rivestack Dashboard. API keys use the rsk_ prefix.

Node capacity

HA clusters run on prepaid node capacity, not per-cluster billing. You buy a pool of nodes once, then Terraform (or the API) provisions clusters that draw from it — there’s no checkout in your terraform apply loop.
1

Buy capacity in the dashboard

In the Rivestack Dashboard, go to Billing → Subscribe to Nodes, choose a server type (starter, growth, or scale) and a quantity, then complete checkout. This is the only step that involves payment.
2

Provision against the pool

terraform apply draws nodes from your pool automatically, matching on server_type. A growth cluster with node_count = 2 consumes two growth nodes from your growth pool. There is no extra charge per cluster.
If your pool has no free nodes of the requested server_type, the API returns 402 Payment Required (no available nodes; subscribe to nodes from the billing page first) and terraform apply fails. Buy more capacity of that server type, then re-run.

Provision with the REST API

If you don’t use Terraform, call the same endpoint directly. Create an API key, buy capacity, then:
Omit server_type to default to starter. The cluster is matched to a pool of the same server type and capacity is found automatically — no pool ID needed.

Quick start

This example creates a 2-node HA cluster with a database and user:

Resources

rivestack_cluster

Manages an HA PostgreSQL cluster.
AttributeTypeRequiredDescription
nameStringYesDisplay name for the cluster
regionStringYesRegion: eu-central, us-east, or ap (Singapore)
server_typeStringNoServer size: starter, growth, or scale
node_countNumberNoNumber of nodes (1-3)
postgresql_versionNumberNoPostgreSQL major version (16, 17, or 18)
db_nameStringNoName of the default database
db_typeStringNoCluster type: ha or core_solo
extensionsListNoExtensions to install at creation time
Read-only attributes: id, host, connection_string, db_user, db_password, status, tenant_id, created_at, updated_at

rivestack_cluster_database

Creates a database on a cluster.
AttributeTypeRequiredDescription
cluster_idStringYesID of the cluster
nameStringYesDatabase name
ownerStringNoDatabase owner username (defaults to cluster’s default user)

rivestack_cluster_user

Creates a database user with an auto-generated password.
AttributeTypeRequiredDescription
cluster_idStringYesID of the cluster
usernameStringYesUsername (letters, numbers, underscores; max 63 chars)
Read-only attributes: id, password (sensitive)

rivestack_cluster_grant

Grants a user access to a database.
AttributeTypeRequiredDescription
cluster_idStringYesID of the cluster
usernameStringYesUsername to grant access to
databaseStringYesDatabase to grant access on
accessStringNoAccess level: read (SELECT) or write (SELECT, INSERT, UPDATE, DELETE)
Grant revocation is not currently supported by the API. Destroying this resource removes it from Terraform state only.

rivestack_cluster_extension

Installs a PostgreSQL extension on a database.
AttributeTypeRequiredDescription
cluster_idStringYesID of the cluster
extensionStringYesExtension name (e.g., vector, pg_trgm, pgcrypto)
databaseStringNoTarget database (defaults to cluster’s primary database)
Extensions cannot be removed from running clusters. Destroying this resource removes it from Terraform state only.

rivestack_cluster_backup_config

Configures automated backups for a cluster.
AttributeTypeRequiredDescription
cluster_idStringYesID of the cluster
enabledBooleanYesWhether automated backups are enabled
scheduleStringNoCron schedule (e.g., "0 3 * * *" for daily at 3 AM)
retention_fullNumberNoNumber of days to retain full backups

Data sources

rivestack_cluster

Read information about an existing cluster.
Read-only attributes: name, region, server_type, node_count, postgresql_version, host, connection_string, db_name, db_user, db_password, db_type, status, health_status, tenant_id, created_at, updated_at

rivestack_server_types

List available server configurations.

rivestack_extensions

List supported PostgreSQL extensions.

Import

Import existing resources into Terraform state: