hashicorp/terraform

backend/azure doesn't find access tokens from az cli when AZURE_CONFIG_DIR is set

gjtaylor opened this issue · 2 comments

Terraform Version

$ terraform version
Terraform v0.12.28
...

Terraform Configuration Files

terraform {
  backend "azurerm" {
    resource_group_name  = "StorageAccount-ResourceGroup"
    storage_account_name = "abcd1234"
    container_name       = "tfstate"
    key                  = "prod.terraform.tfstate"
  }
}

(the resources don't actually need to exist to demonstrate this issue)

Debug Output

https://gist.github.com/gjtaylor/3aa7bad9b7b2961e98214d1bcfd681eb

Crash Output

Expected Behavior

terraform should have used the access token from the az login to authenticate to the remote backend.

Actual Behavior

Error: Error building ARM Config: Error populating Client ID from the Azure CLI: No Authorization Tokens were found - please ensure the Azure CLI is installed and then log-in with 'az login'.

Steps to Reproduce

$ export AZURE_CONFIG_DIR=[not $HOME/.azure]
$ az login
You have logged in. Now let us find all the subscriptions to which you have access...
...
$ terraform init

Additional Context

References

Similar problem in hashicorp/terraform-provider-azurerm#5891

Closing since this has instead been fixed via #26721

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.