planetscalepostgresbranch_role (Resource)

June 1, 2026 ยท View on GitHub

PostgresBranchRole Resource

Example Usage

resource "planetscale_postgres_branch_role" "my_postgresbranchrole" {
  organization = "my-organization"
  database = "ru00w3vqvfr9"
  branch   = "2474dzfubrf3"

  name         = "application-role"

  inherited_roles = [
    "pg_read_all_data",
    "pg_write_all_data",
  ]
}

Schema

Required

  • branch (String) Branch name from list_branches. Example: main.
  • database (String) Database name slug from list_databases. Example: app-db.
  • organization (String) Organization name slug from list_organizations. Example: acme.

Optional

  • inherited_roles (Set of String) Roles to inherit from. Requires replacement if changed.
  • name (String) The name of the role
  • successor (String) The optional role to reassign ownership to before dropping
  • ttl (Number) Time to live in seconds. Requires replacement if changed.

Read-Only

  • access_host_url (String) The database connection string
  • actor_data (Attributes) (see below for nested schema)
  • base_username (String) The base username without branch routing suffix
  • branch_data (Attributes) (see below for nested schema)
  • created_at (String) When the role was created
  • database_name (String) The database name
  • default (Boolean) Whether the role is the default postgres user
  • deleted_at (String) When the role was deleted
  • disabled_at (String) When the role was disabled
  • drop_failed (String) Error message available when dropping the role fails
  • dropped_at (String) When the role was dropped
  • expired (Boolean) True if the credentials are expired
  • expires_at (String) When the role expires
  • id (String) The ID of the role
  • password (String, Sensitive) The plain text password, available only after create
  • private_access_host_url (String) The database connection string for private connections
  • private_connection_service_name (String) The service name to set up private connectivity
  • query_safety_settings (Attributes) (see below for nested schema)
  • updated_at (String) When the role was updated
  • username (String) The database user name

Nested Schema for actor_data

Read-Only:

  • avatar_url (String) The URL of the actor's avatar
  • display_name (String) The name of the actor
  • id (String) The ID of the actor

Nested Schema for branch_data

Read-Only:

  • deleted_at (String) When the resource was deleted, if deleted
  • id (String) The ID for the resource
  • name (String) The name for the resource

Nested Schema for query_safety_settings

Read-Only:

  • require_where_on_delete (String) Require WHERE clause on DELETE statements
  • require_where_on_update (String) Require WHERE clause on UPDATE statements

Import

Import is supported using the following syntax:

In Terraform v1.5.0 and later, the import block can be used with the id attribute, for example:

import {
  to = planetscale_postgres_branch_role.my_planetscale_postgres_branch_role
  id = jsonencode({
    branch       = "..."
    database     = "..."
    id           = "..."
    organization = "..."
  })
}

The terraform import command can be used, for example:

terraform import planetscale_postgres_branch_role.my_planetscale_postgres_branch_role '{"branch": "...", "database": "...", "id": "...", "organization": "..."}'