Skip to content

PostgresCatalog

laktory.models.resources.databricks.PostgresCatalog ¤

Bases: TagsMixin, PostgresCatalogBase

Lakebase Autoscaling (Postgres) Unity Catalog catalog

Registers a Postgres database of a branch as a Unity Catalog catalog, so its tables can be queried from Databricks and used as the destination of synced tables. Can also be declared in the catalogs of a PostgresBranch, which sets spec.branch.

Examples:

import io

from laktory import models

catalog_yaml = '''
catalog_id: app_pg
spec:
  branch: projects/app/branches/production
  postgres_database: app_db
  create_database_if_missing: true
tags:
  domain: app
grants:
- principal: account users
  privileges:
  - USE_CATALOG
  - SELECT
'''
catalog = models.resources.databricks.PostgresCatalog.model_validate_yaml(
    io.StringIO(catalog_yaml)
)
References
BASE DESCRIPTION
catalog_id

The part of the name, chosen by the user when the resource was created

TYPE: str | VariableType

provider_config

Configure the provider for management through account provider

TYPE: PostgresCatalogProviderConfig | None | VariableType DEFAULT: None

spec

Catalog configuration: Postgres database and branch (set automatically when declared in the catalogs of a branch)

TYPE: PostgresCatalogSpec | VariableType

LAKTORY DESCRIPTION
grant

Non-destructive grant for specific principal(s). Adds or updates privileges for the listed principal(s) and leaves grants for all other principals untouched. Use when access is managed from multiple sources (Laktory, Databricks UI, etc.). Mutually exclusive with grants.

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

grants

Authoritative grant list for all principals. Replaces every existing grant on this Catalog - including those set outside Laktory - with only the entries listed here. Use only when Laktory owns all access management for this resource. Mutually exclusive with grant.

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

tags

Tags assigned to the entity as {tag_key: tag_value}. Use a null value for a key-only tag. Each tag is deployed as a separate tag assignment resource.

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

METHOD DESCRIPTION
get_tags_additional_resources

Tag assignment resources for entity (a name or a resource reference).

ATTRIBUTE DESCRIPTION
additional_core_resources
  • catalog grants

TYPE: list

additional_core_resources property ¤

  • catalog grants
  • catalog tags

Unity Catalog objects are named after catalog_id (the Terraform id is the Lakebase path catalogs/{catalog_id}), so they depend on the catalog explicitly.

get_tags_additional_resources(entity_type, entity, tags=None) ¤

Tag assignment resources for entity (a name or a resource reference). Defaults to the tags of this resource.

Source code in laktory/models/resources/databricks/_tagsmixin.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def get_tags_additional_resources(
    self, entity_type: str, entity: str, tags: dict[str, str | None] | None = None
) -> list:
    """
    Tag assignment resources for `entity` (a name or a resource reference).
    Defaults to the `tags` of this resource.
    """
    if tags is None:
        tags = self.tags
    resources = []
    for key, value in (tags or {}).items():
        if entity_type in WORKSPACE_ENTITY_TYPES:
            r = WorkspaceEntityTagAssignment(
                entity_type=entity_type,
                entity_id=entity,
                tag_key=key,
                tag_value=value,
            )
        else:
            r = EntityTagAssignment(
                entity_type=entity_type,
                entity_name=entity,
                tag_key=key,
                tag_value=value,
            )
        resources += [r]
    return resources

laktory.models.resources.databricks.postgrescatalog.PostgresCatalogProviderConfig ¤

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.postgrescatalog.PostgresCatalogSpec ¤

Bases: BaseModel

PARAMETER DESCRIPTION
branch

The resource path of the branch associated with the catalog

TYPE: str | None | VariableType DEFAULT: None

create_database_if_missing

If set to true, the specified postgres_database is created on behalf of the calling user if it does not already exist. In this case, the calling user has a role created for them in Postgres if they do not already have one

TYPE: bool | None | VariableType DEFAULT: None

postgres_database

The name of the Postgres database associated with the catalog

TYPE: str | VariableType