Skip to content

Latest commit

 

History

History
120 lines (84 loc) · 4.01 KB

File metadata and controls

120 lines (84 loc) · 4.01 KB
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.

cozystack_postgres (Resource)

A Cozystack managed PostgreSQL instance, deployed inside a tenant namespace. The postgresql tuning, quorum, deprecated backup, and bootstrap blocks use server defaults.

Example Usage

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"] }
    }
  }
}

Schema

Required

  • name (String) Postgres instance name (metadata.name). Immutable.
  • namespace (String) Tenant namespace the application is created in. Immutable.

Optional

  • 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; overrides resources_preset for any field set. (see below for nested schema)
  • resources_preset (String) Sizing preset applied when resources is 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 (v18v13).
  • wait_for_ready (Boolean) Block on create/update until the tenant's Ready condition is true.
  • wait_timeout (String) Maximum time to wait when wait_for_ready is set (Go duration, e.g. 10m).

Read-Only

  • chart_version (String) Deployed chart version (status.version).
  • endpoints (Attributes) Connection endpoints (from the CNPG <name>-rw/<name>-ro Services). Populated once the instance is ready. (see below for nested schema)
  • id (String) Synthetic identifier in the form namespace/name.
  • ready (Boolean) Whether the application's Ready condition is true.
  • uid (String) Server-assigned object UID (metadata.uid). Stable across updates; changes on recreate.

Nested Schema for databases

Optional:

  • extensions (List of String) Enabled PostgreSQL extensions.
  • roles (Attributes) User roles for this database. (see below for nested schema)

Nested Schema for databases.roles

Optional:

  • admin (List of String) Users with admin privileges.
  • readonly (List of String) Users with read-only privileges.

Nested Schema for resources

Optional:

  • cpu (String) CPU available to each replica (quantity, e.g. 500m).
  • memory (String) Memory available to each replica (quantity, e.g. 512Mi).

Nested Schema for users

Optional:

  • password (String, Sensitive) Password for the user (autogenerated when omitted).
  • replication (Boolean) Whether the user has replication privileges.

Nested Schema for endpoints

Read-Only:

  • host (String) Primary (read-write) service host.
  • port (Number) PostgreSQL port.
  • read_host (String) Replica (read-only) service host.

Import

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