dbt Cloud CLI - Connect to multiple hosts

The problem I’m having

I am trying to use dbt Cloud CLI to work on two different projects on two different dbt Cloud accounts (different organisations).

I have downloaded two dbt_cloud.yml files and I added a dbt-cloud section in dbt_project.yml like the one below, pointing each project to the right id in dbt Cloud:

dbt-cloud:
  project-id: <id_to_the_actual_project> 

One project works fine, but for the other object, I am getting:

Encountered an error loading configuration: dbt_cloud.yml does not contain a project definition with project-id: `12345678732425` and account-host: `cloud.getdbt.com`

Running dbt environment show I can see that the Active host name is set to cloud.getdbt.com, while for this specific organisation, it should be set to something like zr123.us1.dbt.com.

The context of why I’m trying to do this

I work for multiple organisation having different dbt Cloud tenants and I jump between them multiple times per day, so I need to be able to point the CLI to the right tenant for the right project.

What I’ve already tried

I can see that Active host name seems to be set by the context section in dbt_cloud.yml:

version: "1"
context:
  active-host: "cloud.getdbt.com"
  active-project: "1234567890"

If I merge the two dbt_cloud.yml into one (having multiple projects in the projects section) and then manually change active-host to be the right one for the current project, I can make both projects work, but obviously this is not a solution since I need to manually edit dbt_cloud.yml every time I switch.

I have also tried to have each dbt_cloud.yml files inside the project folders, but the dbt Cloud CLI still seems to source its config from the one inside my user directory (C:\Users\myname\.dbt\dbt_cloud.yml).

What I need is to have dbt Cloud CLI to either of the following:

  • Pick the right dbt_cloud.yml file for each project (maybe checking for the files in multiple locations?)
  • Pick the right “active host” based on the “project id” I have in dbt_project.yml.

All in all, it would be very good to have some documentation on how dbt Cloud CLI chooses its settings: the current documentation is very barebones and doesn’t seem to cover my case.