Skip to content

PostgresProject

laktory.models.resources.databricks.PostgresProject ¤

Bases: PostgresProjectBase

Lakebase Autoscaling (Postgres) Project

Top-level container of a managed, autoscaling Postgres: branches, each with endpoints (compute), databases and roles. A production branch with a primary read-write endpoint, a databricks-postgres database and an owner role is created implicitly with the project; declare them with replace_existing: true to manage them.

Lakebase Autoscaling resources follow specific Terraform semantics: changes made outside Terraform are not detected (no drift detection), a value removed from spec is kept by the server, and the Terraform state should be shared (remote backend) when several users manage the same project.

Examples:

import io

from laktory import models

project_yaml = '''
project_id: app
spec:
  pg_version: 17
  display_name: App backend
  default_endpoint_settings:
    autoscaling_limit_min_cu: 0.5
    autoscaling_limit_max_cu: 4.0
branches:
- branch_id: production
  replace_existing: true
  spec:
    no_expiry: true
- branch_id: dev
  spec:
    source_branch: projects/app/branches/production
    ttl: 604800s
'''
project = models.resources.databricks.PostgresProject.model_validate_yaml(
    io.StringIO(project_yaml)
)
References
BASE DESCRIPTION
initial_branch_spec

Configuration for the initial default branch created as part of project creation. Allows overriding branch protection. These settings only apply at creation time and do not affect resources created after project creation

TYPE: PostgresProjectInitialBranchSpec | None | VariableType DEFAULT: None

initial_endpoint_spec

Configuration settings for the initial Read/Write endpoint created inside the initial branch for a newly created project. If omitted, the initial endpoint created will have default settings, without high availability configured. This field does not apply to any endpoints created after project creation. Use spec.default_endpoint_settings to configure default settings for endpoints created after project creation

TYPE: PostgresProjectInitialEndpointSpec | None | VariableType DEFAULT: None

project_id

Part of the resource name

TYPE: str | VariableType

provider_config

Configure the provider for management through account provider

TYPE: PostgresProjectProviderConfig | None | VariableType DEFAULT: None

purge_on_delete

If true, permanently deletes the project (hard delete). If false or unset, performs a soft delete

TYPE: bool | None | VariableType DEFAULT: None

spec

The spec contains the project configuration, including display_name, pg_version (Postgres version), history_retention_duration, and default_endpoint_settings

TYPE: PostgresProjectSpec | None | VariableType DEFAULT: None

LAKTORY DESCRIPTION
branches

Branches of the project. Their parent is set automatically.

TYPE: list[PostgresBranch | VariableType] | VariableType DEFAULT: None

METHOD DESCRIPTION
assign_parents

Set the project path on nested branches and their resources

ATTRIBUTE DESCRIPTION
additional_core_resources
  • branches

TYPE: list

path

Lakebase resource path projects/{project_id}

TYPE: str

additional_core_resources property ¤

  • branches

A branch forked from a sibling (spec.source_branch) is created after it.

path property ¤

Lakebase resource path projects/{project_id}

assign_parents() ¤

Set the project path on nested branches and their resources

Source code in laktory/models/resources/databricks/postgresproject.py
69
70
71
72
73
74
75
76
@model_validator(mode="after")
def assign_parents(self):
    """Set the project path on nested branches and their resources"""
    for b in self.branches or []:
        if b.parent is None:
            b.parent = self.path
        b.assign_parents()
    return self

laktory.models.resources.databricks.postgresproject.PostgresProjectInitialBranchSpec ¤

Bases: BaseModel

PARAMETER DESCRIPTION
is_protected

Whether the initial default branch should be protected from deletion

TYPE: bool | None | VariableType DEFAULT: None


laktory.models.resources.databricks.postgresproject.PostgresProjectInitialEndpointSpec ¤

Bases: BaseModel

PARAMETER DESCRIPTION
autoscaling_limit_max_cu

The maximum number of Compute Units. Minimum value is 0.5

TYPE: float | None | VariableType DEFAULT: None

autoscaling_limit_min_cu

The minimum number of Compute Units. Minimum value is 0.5

TYPE: float | None | VariableType DEFAULT: None

group

Settings for HA configuration of the endpoint

TYPE: PostgresProjectInitialEndpointSpecGroup | None | VariableType DEFAULT: None

no_suspension

When set to true, explicitly disables automatic suspension (never suspend). Should be set to true when provided. Mutually exclusive with suspend_timeout_duration

TYPE: bool | None | VariableType DEFAULT: None

suspend_timeout_duration

Duration of inactivity after which the compute endpoint is automatically suspended. If specified should be between 60s and 604800s (1 minute to 1 week). Mutually exclusive with no_suspension

TYPE: str | None | VariableType DEFAULT: None


laktory.models.resources.databricks.postgresproject.PostgresProjectInitialEndpointSpecGroup ¤

Bases: BaseModel

PARAMETER DESCRIPTION
enable_readable_secondaries

Whether to allow read-only connections to read-write endpoints. Only relevant for read-write endpoints where size.max > 1

TYPE: bool | None | VariableType DEFAULT: None

max

The maximum number of computes in the endpoint group. Currently, this must be equal to min. Set to 1 for single compute endpoints, to disable HA. To manually suspend all computes in an endpoint group, set disabled to true on the EndpointSpec

TYPE: int | VariableType

min

The minimum number of computes in the endpoint group. Currently, this must be equal to max. This must be greater than or equal to 1

TYPE: int | VariableType


laktory.models.resources.databricks.postgresproject.PostgresProjectProviderConfig ¤

Bases: BaseModel

PARAMETER DESCRIPTION
workspace_id

Workspace ID which the resource belongs to. This workspace must be part of the account which the provider is configured with

TYPE: str | None | VariableType DEFAULT: None


laktory.models.resources.databricks.postgresproject.PostgresProjectSpec ¤

Bases: BaseModel

PARAMETER DESCRIPTION
budget_policy_id

The budget policy that is applied to the project

TYPE: str | None | VariableType DEFAULT: None

custom_tags

The effective custom tags associated with the project

TYPE: list[PostgresProjectSpecCustomTags] | None | VariableType DEFAULT: None

default_branch

The full resource path of the default branch of the project

TYPE: str | None | VariableType DEFAULT: None

default_endpoint_settings

The effective default endpoint settings

TYPE: PostgresProjectSpecDefaultEndpointSettings | None | VariableType DEFAULT: None

display_name

The effective human-readable project name

TYPE: str | None | VariableType DEFAULT: None

enable_pg_native_login

Whether to enable PG native password login on all endpoints in this project

TYPE: bool | None | VariableType DEFAULT: None

history_retention_duration

The effective number of seconds to retain the shared history for point in time recovery

TYPE: str | None | VariableType DEFAULT: None

pg_version

The effective major Postgres version number

TYPE: int | None | VariableType DEFAULT: None


laktory.models.resources.databricks.postgresproject.PostgresProjectSpecCustomTags ¤

Bases: BaseModel

PARAMETER DESCRIPTION
key

The key of the custom tag

TYPE: str | None | VariableType DEFAULT: None

value

The value of the custom tag

TYPE: str | None | VariableType DEFAULT: None


laktory.models.resources.databricks.postgresproject.PostgresProjectSpecDefaultEndpointSettings ¤

Bases: BaseModel

PARAMETER DESCRIPTION
autoscaling_limit_max_cu

The maximum number of Compute Units. Minimum value is 0.5

TYPE: float | None | VariableType DEFAULT: None

autoscaling_limit_min_cu

The minimum number of Compute Units. Minimum value is 0.5

TYPE: float | None | VariableType DEFAULT: None

no_suspension

When set to true, explicitly disables automatic suspension (never suspend). Should be set to true when provided. Mutually exclusive with suspend_timeout_duration

TYPE: bool | None | VariableType DEFAULT: None

pg_settings

A raw representation of Postgres settings

TYPE: dict[str, str] | None | VariableType DEFAULT: None

suspend_timeout_duration

Duration of inactivity after which the compute endpoint is automatically suspended. If specified should be between 60s and 604800s (1 minute to 1 week). Mutually exclusive with no_suspension

TYPE: str | None | VariableType DEFAULT: None