Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform always asks for login if AZURE_CONFIG_DIR is different from the default #5891

Closed
ghost opened this issue Feb 25, 2020 · 6 comments · Fixed by #7433
Closed

terraform always asks for login if AZURE_CONFIG_DIR is different from the default #5891

ghost opened this issue Feb 25, 2020 · 6 comments · Fixed by #7433

Comments

@ghost
Copy link

ghost commented Feb 25, 2020

This issue was originally opened by @rnsc as hashicorp/terraform#24193. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.12.21

Terraform Configuration Files

# The default provider configuration
provider "azurerm" {
  subscription_id = "MySubscriptionId"
}

Crash Output

Error: Error building AzureRM Client: 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`.

Expected Behavior

Terraform should support the AZURE_CONFIG_DIR env var (which is supported by Azure CLI).

Actual Behavior

Terraform complains that I'm not logged in, even though I am.

Steps to Reproduce

Configure your env with the AZURE_CONFIG_DIR set to something other than "$HOME/.azure".
Do az login and confirm that the AZURE_CONFIG_DIR is populated with the Azure CLI session files.
Run terraform and it will complain that you need to login.

Additional Context

Azure CLI reference:
https://docs.microsoft.com/en-us/cli/azure/azure-cli-configuration?view=azure-cli-latest#cli-configuration-file

@rnsc
Copy link

rnsc commented Apr 2, 2020

Hello,

Is this on the radar?
Will it be implemented?

Kind regards,

@rnsc
Copy link

rnsc commented Apr 2, 2020

ping @jbardin

@tomklino
Copy link

tomklino commented Jun 18, 2020

I would like to provide some further info if that will help with the issue.

I ran terraform plan with strace watching for file access while AZURE_CONFIG_DIR is set to a directory different than the default. Strace shows the following:

$ strace -e file -f -s99999 -o /tmp/terraform.strace terraform plan
...
4393  openat(AT_FDCWD, "/home/toklinov/.azureconfigs/lutraman/azureProfile.json", O_RDONLY|O_CLOEXEC) = 13
4393  openat(AT_FDCWD, "/home/toklinov/.azure/accessTokens.json", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
...

The first line is showing that terraform is loading the azureProfile.json from the location pointed to by the value at AZURE_CONFIG_DIR, the second line show terraform trying to load the accessTokens.json file from the default location.

I hope this helps in moving this issue further

@ghost
Copy link
Author

ghost commented Jun 25, 2020

This has been released in version 2.16.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.16.0"
}
# ... other configuration ...

@arkiaconsulting
Copy link

We're still having the issue when using an Azure backend state.
Is this on the provider team side, or on terraform one ?

jrauschenbusch pushed a commit to jrauschenbusch/terraform-provider-azurerm that referenced this issue Jun 29, 2020
jrauschenbusch pushed a commit to jrauschenbusch/terraform-provider-azurerm that referenced this issue Jun 29, 2020
jrauschenbusch pushed a commit to jrauschenbusch/terraform-provider-azurerm that referenced this issue Jun 29, 2020
@ghost
Copy link
Author

ghost commented Jul 24, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@hashicorp hashicorp locked and limited conversation to collaborators Jul 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants