<p>I have two emails associated with two separate gcloud projects.</p>
<p>I can easily switch the projects with:</p>
<pre><code>$ gcloud auth list
  Credentialed Accounts
ACTIVE  ACCOUNT
        first@project1
*       second@project2

$ gcloud config set account first@project1
</code></pre>
<p>I can then see, that gcloud did change the active account. I can also do this with:</p>
<pre><code>$ gcloud config configurations list
...
$ gcloud config configurations set project1
</code></pre>
<p>And I can see the active configuration changes.</p>
<p>However it does not seem to have any effect for <code>kubectl</code> and <code>terraform</code> commands as they still use the previous configuration.</p>
<p>What am i doing wrong? How should I switch between the projects? It seems it has something to do with <code>application-default</code> account, but that looks it cannot be easily switched without relogin?</p>
<p><strong>Edit</strong>: to precise the question:</p>
<p>What would be a correct sequence of commands to switch between gcloud auths (eg. first@project1, second@project2) so that it is usable in Kubernetes, Terraform and others?</p>

Vojtěch
<p>SDK provides the following command, this helps in applying credentials to all API calls that make use of the Application Default Credentials client library.</p>
<p><a href="https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#running-terraform-on-your-workstation" rel="nofollow noreferrer">Terraform</a> is one of the classic applications that have this dependency.</p>
<pre><code>gcloud auth application-default login
</code></pre>
<p>Here is the <a href="https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login" rel="nofollow noreferrer">documentation</a> for the above command.</p>
