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.
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. 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.
| Attribute | Type | Required | Description |
|---|
name | String | Yes | Display name for the cluster |
region | String | Yes | Region: eu-central, us-east, or ap (Singapore) |
server_type | String | No | Server size: starter, growth, or scale |
node_count | Number | No | Number of nodes (1-3) |
postgresql_version | Number | No | PostgreSQL major version (16, 17, or 18) |
db_name | String | No | Name of the default database |
db_type | String | No | Cluster type: ha or core_solo |
extensions | List | No | Extensions 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.
| Attribute | Type | Required | Description |
|---|
cluster_id | String | Yes | ID of the cluster |
name | String | Yes | Database name |
owner | String | No | Database owner username (defaults to cluster’s default user) |
rivestack_cluster_user
Creates a database user with an auto-generated password.
| Attribute | Type | Required | Description |
|---|
cluster_id | String | Yes | ID of the cluster |
username | String | Yes | Username (letters, numbers, underscores; max 63 chars) |
Read-only attributes: id, password (sensitive)
rivestack_cluster_grant
Grants a user access to a database.
| Attribute | Type | Required | Description |
|---|
cluster_id | String | Yes | ID of the cluster |
username | String | Yes | Username to grant access to |
database | String | Yes | Database to grant access on |
access | String | No | Access 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.
| Attribute | Type | Required | Description |
|---|
cluster_id | String | Yes | ID of the cluster |
extension | String | Yes | Extension name (e.g., vector, pg_trgm, pgcrypto) |
database | String | No | Target 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.
| Attribute | Type | Required | Description |
|---|
cluster_id | String | Yes | ID of the cluster |
enabled | Boolean | Yes | Whether automated backups are enabled |
schedule | String | No | Cron schedule (e.g., "0 3 * * *" for daily at 3 AM) |
retention_full | Number | No | Number 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:
Links