Managing Multiple dbt Cloud Projects? Try dbt-switch.
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:
- You cannot associate a single git account to multiple dbt Cloud projects
- 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:
- Install dbt-switch: uv tool install dbt-switch
- Initialize the configuration file: dbt-switch init
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
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
5. Verify the current active project: dbt-switch list
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
Curious to learn more and/or contribute? View the source code here and read more about dbt-switch in the project docs here!