Start of Main Content

One of our core offerings at Brooklyn Data is building, architecting, and scaling dbt projects for small organizations to large enterprises. Because of this, our team of data experts are constantly managing and juggling multiple dbt Cloud projects on a regular basis.

If you are a consultant, in professional services, or have had to manage different dbt Cloud projects across different accounts, you may have come across the following two minor, pain points:

  1. You cannot associate a single git account to multiple dbt Cloud projects
  2. It is a bit cumbersome to switch between dbt Cloud projects for local development in the Cloud CLI

As of this writing, there is no current workaround for the former raised issue. However, for the latter, there is an existing manual workflow for working around switching between projects.

This workflow involves maintaining a single dbt_cloud.yml file and then manually changing the active host and project within the context key configuration:

version: "1"

context:

active-project: "<Need to switch between active projects to use CLI>"

active-host: "<Need to switch between active hosts to use CLI>"

projects:

- project-name: "<project-name>"

...

- project-name: "<project-name>"

...

Again, this isn’t a big deal, but if you do this 3–5+ times in a day, 5 times a week, it can get cumbersome! To make life slightly easier, I built a simple utility with the goal of making the switch between different projects, across different accounts a trivial task for anyone that develops for multiple organizations.

How does it work?

The idea is very simple:

  • All of your projects and credentials are maintained within
    one ~.dbt/dbt_cloud.yml file
  • Account-specific “active context” configurations are stored in a ~.dbt/dbt_switch.yml file
  • Easily switch out the active host and project via the CLI

dbt-switch (https://github.com/jairus-m/dbt-switch)

Using this CLI utility is as simple as the following:

  1. Install dbt-switch: uv tool install dbt-switch
Screen showing the dbt-switch installation globally on a computer.
dbt-switch is installed globally.
  1. Initialize the configuration file: dbt-switch init
Screen showing the initialization of the dbt-switch configuration file.
The configuration is created in ~/.dbt/dbt_switch.yml

 

Build Smarter, Scalable Data Models with dbt Experts

From startups to enterprises, Brooklyn Data helps organizations architect, manage, and scale dbt Cloud projects that unlock reliable, analytics-ready data. Our team ensures your dbt workflows are efficient, maintainable, and built for growth.

3. Add projects (an interactive mode also exists!)

dbt-switch add my-project --host https://cloud.getdbt.com --project-id 12345

dbt-switch add client-project --host https://cloud.getdbt.com --project-id 54321

A screen showing how to add projects to your dbt_switch.yml file.

NOTE: You must merge your dbt_cloud.ymlconfigurations files (from the different accounts) into one master file before switching between projects.

Read more about that process here.

4. Switch to a project: dbt-switch -p my-project

Screen showing a specific dbt-project that was switched into.
Screen showing a specific dbt-project that was switched into.

5. Verify the current active project: dbt-switch list

A screen showing the process of verifying the current project.
The “context” key of dbt_cloud.yml will now use the host and project id of “my-project”.

You should be able to see an asterisk (*) and flag ([ACTIVE]) placed next to the current active project.

Once configured, all you need you need to do is to run dbt-switch -p in the terminal and you’re off to the races!

Curious to learn more and/or contribute? View the source code here and read more about dbt-switch in the project docs here!

 

Published:
  • Data and Analytics Engineering
  • Data Tooling Optimization
  • Data Transformation
  • Dbt
  • dbt

Take advantage of our expertise on your next project