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, so 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, with 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.
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.

rivestack_cluster_user

Creates a database user with an auto-generated password.
Read-only attributes: id, password (sensitive)

rivestack_cluster_grant

Grants a user access to a database.
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.
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.

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: