Introducing a new way to review your PRs.

Read the announcement

bruin-data / bruin

Build data pipelines with SQL and Python, ingest data from different sources, add quality checks, and build end-to-end flows.

View on GitHub

21 documents · Updated Nov 20, 2026

docs / connection-configuration

Connection configuration

Connections give Bruin a named way to reach a data source, data store, or service. Each connection has a type and a type-specific set of target and authentication fields. A selected environment turns those definitions into runtime clients that SQL assets, ingestion assets, and other runtimes can use. Data connectivity and ingestion describes the wider data movement model.

Connection model

Named typed connections

A connection name is the stable identity that pipeline assets use. The connection type selects the fields that are valid and the client or connector behavior that Bruin uses.

An environment can contain several connections of one type. A pipeline can set a default connection for a type, while an asset can name a connection directly and override that default. Ingestion assets commonly use separate source and destination names. Ingestion operators describes how those names enter an ingestion run.

default_connections:
  postgres: analytics-db

# An asset may override the pipeline default.
connection: reporting-db

References: pkg/…/manager.go• L27-304 pkg/…/manager.go• L361-380 docs/…/connections.md• L45-78

Connection types

The connection type set covers warehouses, databases, object stores, files, APIs, messaging systems, and runtime services. Each type has a dedicated configuration shape so its target fields and authentication choices can be checked as one unit.

Source-specific API connections such as Odoo use the same named and typed model. The type name can differ from the direct client or ingestion connector: Vitess and PlanetScale use MySQL-compatible clients for direct access but keep their own ingestion schemes.

Some types support extra runtime rules. Database and warehouse connections can route queries through Bruin Cloud. Supported direct-access database types can be read-only. Connection metadata can also limit how many assets use one connection at the same time.

Connector coverage belongs in Source and destination integrations.

References: pkg/…/manager.go• L27-191 pkg/…/connections.go• L18-43 pkg/…/connections.go• L1050-1063 pkg/…/connections.go• L524-576 pkg/…/connection.go• L1425-1488 pkg/…/connection.go• L4257-4283

BigQuery connection controls

Google Cloud Platform connections represent BigQuery access and can carry controls that affect query safety, source reads, and Iceberg output. An optional read_only flag blocks write operations at the BigQuery client. storage_uri provides a connection-level storage location for Iceberg assets when the asset does not set one. read_api selects the read path when a BigQuery source uses the ingestion runtime.

The read-only flag is optional and is preserved only when enabled. The other optional controls are also preserved when set. The connection manager passes these controls into the BigQuery client when it creates the runtime connection.

References: pkg/…/connections.go• L82-99 pkg/…/bigquery_read_only_test.go• L11-61 pkg/…/connection.go• L394-461 pkg/…/operator.go• L96-105 pkg/…/operator.go• L199-209

DuckDB connection modes

DuckDB connections support either a local database path or a remote Quack service. The remote mode needs quack, host, and token; it cannot combine remote fields with a local path, read-only mode, or lakehouse settings. Local connections can also set memory, thread, temporary storage, and insertion-order limits for the DuckDB process.

The connection manager checks these mode rules before it creates the client. It passes the resource settings to DuckDB when it opens the local or remote connection, so an invalid setting prevents that connection from becoming available.

References: pkg/…/connections.go• L1115-1140 pkg/…/connection.go• L2198-2240

Connection limits

Connection metadata can include max_concurrent_assets. This is a positive limit on the number of active assets that may use one connection. The scheduler uses it after asset connection names are resolved.

Use this limit when the external system has a lower request or session limit than the Bruin worker pool. Omit it when the connection has no extra limit.

References: pkg/…/connections.go• L18-29 pkg/…/manager.go• L2415-2459 pkg/…/scheduler.go• L400-492

Configuration shape

Project configuration

The project configuration file is .bruin.yml. It names the default environment and stores a map of environments. Each environment owns its connection set, so the same connection name can point to different systems in development and production.

default_environment: default
environments:
  default:
    connections:
      postgres:
        - name: analytics-db
          host: localhost
          port: 5432
          database: analytics
          username: bruin
          password: ${ANALYTICS_DB_PASSWORD}

The YAML key is the connection type. Its value is a list because one environment can hold more than one connection of that type. A missing file creates an empty default configuration. Bruin also keeps the file out of version control through .gitignore.

References: pkg/…/manager.go• L306-343 pkg/…/manager.go• L446-488 pkg/…/manager.go• L763-809

Environment selection

An environment is the complete connection set for one run. Bruin selects default_environment when it loads the configuration. Commands can select another existing environment before they build runtime clients.

Selection is separate from client creation. A name that exists in one environment is not available in another unless that environment defines the name too. This keeps local, test, and production systems separate while pipeline definitions stay stable.

References: pkg/…/manager.go• L402-415 pkg/…/manager.go• L476-487 pkg/…/manager_test.go• L1731-1776

Environment values

Connection values can use ${NAME} references. Bruin expands references that match process environment variables while it decodes the YAML document. The expansion follows the typed configuration shape, so it can reach nested connection fields and values inside lists or maps.

During runtime manager creation, Bruin also resolves placeholders in string fields before it builds each client. An absent variable becomes an empty string at this stage. The process that runs Bruin must provide every variable needed by the selected connections.

Bruin can also receive the complete YAML document through BRUIN_CONFIG_FILE_CONTENT. When this variable is set, the manager decodes that content instead of reading the configured file path.

References: pkg/…/manager.go• L446-461 pkg/…/manager.go• L599-760 pkg/…/connection.go• L4542-4579 pkg/…/connection_test.go• L881-986

Local paths

Relative paths in supported file-backed connection fields are resolved from the configuration file directory. Absolute Unix and Windows paths stay tied to the machine that runs Bruin. URI locations such as s3://, gs://, and file:// remain locations rather than local paths when the connection type supports them.

This rule applies to credential files, SSL files, local database files, and Iceberg catalog or storage paths. A relative path is portable as configuration, but the referenced file or directory must exist in every environment that uses the connection.

References: pkg/…/manager.go• L417-444 pkg/…/manager.go• L482-580 pkg/…/manager_test.go• L1321-1358 pkg/…/manager_test.go• L1438-1565

Iceberg locations

Iceberg is a first-class connection type for an Apache Iceberg destination. An Iceberg connection joins a catalog with the place where table data files live.

The catalog type selects the catalog service or file form. The storage type selects S3-compatible storage, GCS, or local storage. Storage can inherit the catalog warehouse when its block is empty. BigQuery connections can also provide storage_uri as a connection-level default for BigQuery Iceberg assets.

AreaSupported formsMain purpose
CatalogGlue, SQLite, Postgres, REST, Hive, Hadoop, SQL, R2Stores Iceberg table and namespace metadata
StorageS3, GCS, localStores table data files

Catalog and storage settings can include paths, hosts, regions, buckets, endpoints, and authentication. These settings describe one destination to the ingestion runtime rather than a general-purpose database client.

References: pkg/…/iceberg.go• L6-25 pkg/…/iceberg.go• L39-92 pkg/…/connections.go• L82-97 pkg/…/connections.go• L1481-1507 pkg/…/manager.go• L553-566 pkg/…/operator.go• L96-105 pkg/…/operator.go• L199-209

Credential handling

Authentication fields

Each typed connection separates target details from authentication fields. Common authentication forms include user and password pairs, API keys, access and refresh tokens, cloud access keys, named profiles, application default credentials, inline service account data, and paths to key or certificate files.

Some types support more than one authentication path. Athena accepts static AWS keys or a named profile. Google Cloud connections accept inline service account data, a service account file, an access token, or application default credentials. Snowflake accepts a password, token, inline private key, or private-key path. The type schema and client builder define which combinations are valid.

References: pkg/…/connections.go• L71-95 pkg/…/connections.go• L199-250 pkg/…/connections.go• L599-616 pkg/…/connection.go• L392-435 pkg/…/connection.go• L551-581

Sensitive fields

A sensitive field can grant access and must not appear in normal output. Connection types mark inline secrets with sensitive and mark some credential-file paths with sensitive_file. These marks give configuration and log-protection paths a shared way to find values that need protection.

The connection list surface reports field names instead of field values. Log masking also handles secrets in plain text, escaped URI form, and encoded form. A complete URI or option map that can contain authentication data must be marked as sensitive as a whole. Use dedicated typed fields when the connection type provides them so the masking path can collect them reliably.

References: pkg/…/connections.go• L70-95 pkg/…/connections.go• L599-616 pkg/…/connections.go• L1467-1502 pkg/…/mask.go• L47-61 pkg/…/mask.go• L163-188

Credential files

A credential-file field points to a file whose contents are private. Bruin resolves supported relative paths against .bruin.yml. Clients or connector processes then read the file when they need the credential.

The path is not the secret itself, but it is not safe to publish when it identifies private material. The file must be present and readable in the runtime environment. Inline credentials and file credentials are not interchangeable unless the connection type supports both.

References: pkg/…/connections.go• L82-95 pkg/…/connections.go• L599-616 pkg/…/manager.go• L489-579 pkg/…/mask.go• L171-188

Iceberg credentials

Iceberg keeps catalog and storage credentials in dedicated authentication fields. Catalog REST credentials use catalog credential or token fields. A SQL catalog can use a URI that contains a password. S3, GCS, and other storage credentials belong in the storage authentication block.

Iceberg properties is a pass-through for non-secret connector parameters. It is not redacted. Do not put a password, token, or key in that map. Use the dedicated catalog or storage authentication fields instead.

References: pkg/…/iceberg.go• L27-92 pkg/…/connections.go• L1481-1502 pkg/…/manager_test.go• L2065-2087

Configuration management

Configuration sources

The local manager reads .bruin.yml or a selected configuration file and presents the selected environment to the rest of the system. Secret backends can provide named connections outside the local file while keeping the same lookup contract for runtimes.

The local configuration manager preserves the project-level environment model. An external secret backend owns its storage and retrieval rules, but a runtime still asks for a named connection instead of knowing where the definition came from. Backend-specific behavior belongs in Secrets management.

References: pkg/…/manager.go• L446-461 pkg/…/secrets.go• L5-17 pkg/…/aws_secretsmanager.go• L101-236 pkg/…/azure_keyvault.go• L176-310 pkg/…/doppler.go• L131-244 pkg/…/vault.go• L511-594

Secret-backed connection records

Secret backends store each connection as a typed record. The record names a connection type and supplies its typed details. Bruin feeds that record through the same connection configuration and runtime client path used by local YAML.

Some backends can list records and merge them into one connection set. This lets a caller load a complete external configuration while preserving the same connection names and type rules as a project environment.

References: pkg/…/aws_secretsmanager.go• L167-236 pkg/…/azure_keyvault.go• L242-310 pkg/…/doppler.go• L185-244 pkg/…/vault.go• L425-462 pkg/…/manager.go• L211-229

Secret lookup outcomes

Secret-backed managers can expose ResolveConnection when a caller needs the reason for a failed lookup. A missing secret has a distinct result, so the public lookup can return the normal missing-connection response without producing a warning. Other failures remain visible.

Backends cache resolved clients and connection details after a successful lookup. Later runtime requests use the same shared contract without knowing how to call the selected secret service.

References: pkg/…/manager.go• L197-229 pkg/…/notfound.go• L10-31 pkg/…/aws_secretsmanager.go• L101-165 pkg/…/azure_keyvault.go• L176-240 pkg/…/doppler.go• L131-183 pkg/…/vault.go• L357-423

Bruin Cloud connection management

A Bruin Cloud connection stores the API token and optional API URL used by Cloud commands. The configuration manager searches all environments and permits a Cloud command to resolve one only when exactly one configured connection has a token.

Cloud login updates the selected connection without replacing unrelated YAML content. It also records the default team, protects the configuration file with restrictive permissions, and checks that the file did not change during the update. Removing the connection clears the Cloud team value as part of the same configuration change.

The default team is top-level Cloud configuration rather than an environment value. Updates preserve environment-variable placeholders, comments, and key order. An empty team removes the setting.

References: pkg/…/manager.go• L325-353 pkg/…/connections.go• L2349-2359 pkg/…/cloud_connections.go• L15-220 pkg/…/cloud.go• L13-60 pkg/…/cloud_connections_test.go• L11-54

Connection lifecycle

The connection CLI manages the local connection lifecycle. It can list connection names, add a typed connection, delete a connection from one environment, and test a connection when its client supports a connectivity check.

The add flow accepts interactive input or typed values supplied by flags and scripts. It checks the target environment and connection type, decodes the supplied fields into the typed shape, and persists the selected configuration. Delete resolves the name to its type before it removes the matching entry.

The main lifecycle is:

  1. Select an environment and configuration source.
  2. Choose a registered connection type and name.
  3. Supply fields for that type.
  4. Validate the connection shape and metadata.
  5. Persist the configuration.
  6. Build a runtime client when a run or connection test needs it.

This diagram shows how a named configuration becomes a client used by an asset.

flowchart LR
    A[Configuration source] --> B[Selected environment]
    B --> C[Named typed connection]
    C --> D[Validation and path preparation]
    D --> E[Runtime client]
    E --> F[Asset or connection test]

References: pkg/…/manager.go• L863-904 pkg/…/manager.go• L2058-2408 pkg/…/manager.go• L394-415 cmd/connections.go• L22-290

Environment lifecycle

Environment management keeps connection sets isolated while allowing controlled reuse. A new environment starts with an empty connection set. A clone copies named connections from an existing environment and can use a new schema prefix.

An environment can be renamed or deleted through the configuration manager. A rename updates the default and selected environment names when needed. The last remaining environment cannot be deleted. Connection merges add names that are not already present and do not replace an existing connection with the same name.

References: pkg/…/manager.go• L2471-2663 pkg/…/manager.go• L2679-2858

Concurrency-safe updates

Runtime clients are created for many connection types in parallel. Shared connection indexes are updated under a lock so concurrent client creation does not corrupt the manager or lose a connection.

Every usable connection must have matching connection details and a type. Those details support masking, scheduling, connector choice, and other runtime work.

References: pkg/…/connection.go• L173-339 pkg/…/connection.go• L4544-4776 pkg/…/connection_test.go• L1108-1144 pkg/…/connection_test.go• L1416-1439

Runtime connection abstraction

Shared lookup contract

Runtimes use a small shared connection abstraction instead of reading .bruin.yml directly. A runtime can request a connection by name and receive the typed client needed for its work. Consumers that need scheduling, display, or connector data can request the original details and the connection type as well.

The same contract supports local configuration and secret-backed managers. An optional resolver interface lets a backend return the reason for a failed lookup. A plain lookup returns nil when no connection is available.

References: pkg/…/manager.go• L197-229 pkg/…/connection.go• L341-362 pkg/…/secrets.go• L5-17

Runtime client construction

The runtime manager converts the selected environment into named clients and indexes them by connection name. It keeps the usable client and the original connection details as a pair. It also records the configuration type for consumers that need to distinguish connector behavior.

Most configured connections create a typed runtime client. A generic connection is the exception: its value remains available as connection data instead of becoming a service client. Client creation runs across connection lists in parallel and returns a collection of build errors. Context-aware construction passes cancellation and deadlines to initializers that support them. DuckDB construction also carries its selected local or remote mode and resource limits into the client. BigQuery construction carries its read-only setting, read API, and connection-level Iceberg storage URI into the client.

This diagram shows the shared path from environment selection to runtime work.

sequenceDiagram
    participant Asset as Asset runtime
    participant Contract as Connection contract
    participant Manager as Runtime manager
    participant System as External system

    Asset->>Contract: Request connection by name
    Contract->>Manager: Resolve client and details
    Manager-->>Contract: Typed client and metadata
    Contract-->>Asset: Client or connector URI
    Asset->>System: Query or transfer data

References: pkg/…/manager.go• L197-229 pkg/…/connection.go• L341-362 pkg/…/connection.go• L392-446 pkg/…/connection.go• L2198-2250 pkg/…/connection.go• L4542-4776 pkg/…/connection_test.go• L881-986 pkg/…/connection_test.go• L1416-1439

Connector representations

Some clients serve two roles. They support direct runtime access and can produce a connector URI for an ingestion process. The connection type remains the source of truth for both paths.

Vitess and PlanetScale show this split. Their direct clients use the shared MySQL client shape, while their ingestion URIs use dedicated schemes. This keeps connector behavior distinct without forcing direct runtime users to learn a second client interface.

References: pkg/…/connections.go• L524-560 pkg/…/connection.go• L1425-1488 pkg/…/connection_test.go• L277-336

Snowflake warehouse variants

Snowflake assets can request a warehouse different from the configured default. An empty request or a request equal to the configured warehouse uses the base client. Another warehouse gets a separate client that the manager reuses for later requests with the same connection and warehouse.

This keeps request-specific warehouse choice within the shared connection abstraction. It avoids opening a new client for every asset while preserving the base connection settings.

References: pkg/…/connections.go• L599-616 pkg/…/connection.go• L450-549 pkg/…/connection_test.go• L1034-1083

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the YAML type name, typed field shape, generated schema, connection add/delete paths, and runtime manager registration aligned.
  • When adding or renaming a credential field, update its sensitive or sensitive-file mark and every masking path that protects its value or file contents.
  • When adding a nested or free-form connection field, decide whether typed environment expansion and secret masking can reach it.
  • When adding or changing a read-only, read API, or cloud-routing field, keep the typed schema, supported connection types, client options, runtime routing, and connection tests aligned.
  • When changing BigQuery connection controls, keep read_only, read_api, and storage_uri aligned across YAML and JSON output, schema behavior, client creation, ingestion behavior, and the asset-level storage URI fallback.
  • When changing DuckDB fields, keep local-path and Quack mode requirements aligned across the schema, mode validation, client options, and connector behavior.
  • When adding DuckDB resource controls, keep their typed values and zero or negative-value behavior aligned with the options accepted when the client opens.
  • When changing environment or configuration-source selection, check selected-environment lookup, recursive environment expansion, path resolution, and secret-backend error context together.
  • When changing runtime manager construction, keep placeholder expansion, context propagation, parallel error collection, and client/detail/type registration aligned.
  • When changing local path rules, check Unix paths, Windows anchored paths, URI paths, and the connector process that reads the path.
  • When changing Iceberg catalog or storage fields, keep dedicated credential fields separate from the unredacted properties map.
  • When changing connection metadata, check scheduler limit resolution and all runtimes that read connection details.
  • When changing a client or connector URI contract, check both direct runtime users and ingestion operators. Pay special attention to types that reuse another client.
  • When changing manager registration, keep the usable-client, detail, and type indexes aligned for every connection name.
  • When changing environment clone or merge behavior, preserve name uniqueness and ensure the selected and default environment names still refer to existing environments.
  • When changing Bruin Cloud login, team updates, or removal, keep single-connection resolution, token validation, team state, file permissions, YAML preservation, and concurrent-file change checks aligned.
  • When changing secret lookup errors, preserve the distinction between a missing secret and a backend or configuration failure.
  • When changing context-aware connection initialization, preserve cancellation and deadline propagation for every initializer that supports a run context.
  • When changing Snowflake warehouse selection, preserve reuse of the base client and cached override clients for the same connection and warehouse.

Important failure modes

TriggerConsequenceGuard
The selected or default environment does not exist.Configuration load or command setup stops before a run can build connections.Define the environment in .bruin.yml and select an existing environment explicitly when needed.
An asset names a connection that is absent from the selected environment.Validation or runtime lookup reports a missing connection.Keep asset names, pipeline defaults, and environment connection names consistent.
A required environment variable is absent.Configuration can retain the placeholder, or runtime construction can replace it with an empty string. The client or external system can reject the value.Provide all referenced variables in the process that runs the selected environment.
BRUIN_CONFIG_FILE_CONTENT contains stale or invalid YAML.The supplied content is loaded instead of the configured file and can prevent configuration setup.Treat the variable as the active configuration source and validate its complete YAML document.
A typed connection has missing or conflicting authentication fields.The manager cannot create the client or the external system rejects it.Follow the type-specific authentication choices and required fields.
A credential or SSL file is missing or unreadable.Client or connector creation fails.Deploy each referenced file at its resolved path and use suitable file permissions.
A secret is placed in an unmarked field or Iceberg properties.Logs or generated connector data can expose the value.Use the connection type's dedicated sensitive field or authentication block.
A secret backend cannot find a named secret.Lookup returns the normal missing-connection result without a warning-level backend error.Store the record under the requested name and use resolver errors when the cause matters.
A usable client has no matching connection details or type.Runtime work may start while masking, scheduling, or connector selection cannot see the connection.Keep the usable-client, detail, and type indexes paired for every registered name.
max_concurrent_assets is zero, negative, or not an integer.Configuration or scheduler setup rejects the connection limit.Use a positive integer or omit the limit.
A read-only connection is configured without its read-only setting.A client that should reject writes can allow them.Set read_only: true on supported database and BigQuery connections when the source must be query-only.
A BigQuery Iceberg asset has no storage URI on the asset or its connection.BigQuery cannot create the Iceberg table because it has no location for table data.Set the asset-level storage URI or provide storage_uri on the BigQuery connection.
More than one Bruin Cloud connection is configured.Cloud command setup stops because the target connection is ambiguous.Keep one Bruin Cloud connection across environments used by Cloud commands.
A Snowflake warehouse override cannot build a client.The asset cannot use the requested warehouse.Use a valid warehouse and retain the base connection's required authentication fields.
A connection type is registered in configuration but not in runtime manager construction.The connection remains configured but no usable client or connection data is available to assets.Register the type in the shared manager construction path and keep its type index aligned.
A connection reuses a direct client but emits the wrong ingestion scheme.Direct tests can pass while ingestion cannot select the correct connector.Keep direct client construction and connector URI generation aligned with the connection type.
A context-aware initializer receives a cancelled context or passed deadline.That connection fails to initialize and its error is returned with other manager build errors.Pass a run-scoped context and set deadlines that match the external system's expected connection time.
DuckDB remote fields are used without quack: true, or local-only fields are used with it.The manager rejects the connection before client creation.Use either a local path or the complete Quack host and token form. Do not mix the two modes.
A DuckDB memory, thread, temporary-storage, or insertion-order setting is invalid.DuckDB rejects the option and the connection is not available to assets.Use values and formats accepted by DuckDB for the selected resource setting.

Key files

FileWhy to read it
pkg/…/manager.goDefines project configuration, environment selection, typed environment expansion, path preparation, connection management, environment lifecycle, and persistence behavior.
pkg/…/connections.goDefines typed connection fields, sensitive-field marks, cloud-routing options, connection metadata, BigQuery query and storage controls, DuckDB modes and resource controls, Odoo source settings, and type lookup data.
pkg/…/iceberg.goDefines Iceberg catalog, storage, and authentication choices.
pkg/…/connection.goShows how a selected environment becomes named runtime clients, details, types, connector behavior, context-aware initialization, BigQuery controls, DuckDB options, Odoo client registration, and cached Snowflake warehouse variants.
pkg/…/bigquery_read_only_test.goConfirms that the BigQuery read-only option is optional and survives supported configuration serialization, and that the storage URI remains part of the connection shape.
pkg/…/manager_test.goConfirms configuration loading, environment behavior, path resolution, Iceberg shape, and connection management rules.
pkg/…/connection_test.goConfirms named lookup, client construction, connection-detail pairing, parallel updates, connector URIs, context behavior, and Snowflake warehouse variants.
pkg/…/mask.goShows how marked inline secrets and credential-file contents are protected in output.
cmd/connections.goDefines the user-facing list, add, delete, and test workflows for local connections.
pkg/…/secrets.goDefines lookup contracts shared by local and external secret-backed connection managers.
pkg/…/notfound.goDefines shared missing-secret classification and log-level policy for external backends.
pkg/…/vault.goShows how Vault reads or lists typed connection records and exposes the shared lookup contract.
pkg/…/aws_secretsmanager.goShows how AWS Secrets Manager turns a named secret into a typed runtime connection.
pkg/…/azure_keyvault.goShows how Azure Key Vault turns a named secret into a typed runtime connection.
pkg/…/doppler.goShows how Doppler retrieves and converts named connection records.
pkg/…/scheduler.goShows how connection metadata can limit asset concurrency.