| page_title | cozystack_postgres Resource - cozystack |
|---|---|
| subcategory | |
| description | A Cozystack managed PostgreSQL instance, deployed inside a tenant namespace. The postgresql tuning, quorum, deprecated backup, and bootstrap blocks use server defaults. |
A Cozystack managed PostgreSQL instance, deployed inside a tenant namespace. The postgresql tuning, quorum, deprecated backup, and bootstrap blocks use server defaults.
resource "cozystack_postgres" "app" {
name = "app"
namespace = "tenant-root"
replicas = 2
version = "v18"
size = "20Gi"
users = {
app = { password = "change-me" }
}
databases = {
appdb = {
extensions = ["postgis"]
roles = { admin = ["app"] }
}
}
}name(String) Postgres instance name (metadata.name). Immutable.namespace(String) Tenant namespace the application is created in. Immutable.
databases(Attributes Map) Databases keyed by name. (see below for nested schema)external(Boolean) Enable external access from outside the cluster.replicas(Number) Number of PostgreSQL replicas.resources(Attributes) Explicit CPU and memory per replica; overridesresources_presetfor any field set. (see below for nested schema)resources_preset(String) Sizing preset applied whenresourcesis omitted.size(String) Persistent volume size (quantity, e.g.10Gi).storage_class(String) StorageClass used to store the data.users(Attributes Map) PostgreSQL users keyed by user name. (see below for nested schema)version(String) PostgreSQL major version (v18…v13).wait_for_ready(Boolean) Block on create/update until the tenant'sReadycondition is true.wait_timeout(String) Maximum time to wait whenwait_for_readyis set (Go duration, e.g.10m).
chart_version(String) Deployed chart version (status.version).endpoints(Attributes) Connection endpoints (from the CNPG<name>-rw/<name>-roServices). Populated once the instance is ready. (see below for nested schema)id(String) Synthetic identifier in the formnamespace/name.ready(Boolean) Whether the application'sReadycondition is true.uid(String) Server-assigned object UID (metadata.uid). Stable across updates; changes on recreate.
Optional:
extensions(List of String) Enabled PostgreSQL extensions.roles(Attributes) User roles for this database. (see below for nested schema)
Optional:
admin(List of String) Users with admin privileges.readonly(List of String) Users with read-only privileges.
Optional:
cpu(String) CPU available to each replica (quantity, e.g.500m).memory(String) Memory available to each replica (quantity, e.g.512Mi).
Optional:
password(String, Sensitive) Password for the user (autogenerated when omitted).replication(Boolean) Whether the user has replication privileges.
Read-Only:
host(String) Primary (read-write) service host.port(Number) PostgreSQL port.read_host(String) Replica (read-only) service host.
Import is supported using the following syntax:
The terraform import command can be used, for example:
# Postgres instances are imported as "<namespace>/<name>".
terraform import cozystack_postgres.app tenant-root/app