terraform azurerm : Error waiting for the Azure CLI: exit status 1
Asked Answered
Q

5

7

When trying to run terraform locally with azurerm provider on my machine, I receive this error :

Error: Error building account: Error getting authenticated object ID: Error parsing json result from the Azure CLI: Error waiting for the Azure CLI: exit status 1

I followed this link : https://github.com/terraform-providers/terraform-provider-azurerm/issues/3686#issuecomment-523983734

but the az account get-access-token works.

Any ideas?

Quindecennial answered 24/3, 2020 at 20:10 Comment(0)
Q
14

Since my organization is using a self-signed certificate to control internet traffic, the az cli is not working as usual. To diagnose, you should run this command :

az ad signed-in-user show

It will show you a very clear message to workaround this issue.

https://github.com/Azure/azure-cli/blob/dev/doc/use_cli_effectively.md#working-behind-a-proxy

I exported the CA certificate from any website from Chrome in Base64 and copied the string in the pem file as indicated in the previous link. It worked!

On Windows : Append the certificate in C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\certifi\cacert.pem

Hope this helps someone!

Quindecennial answered 24/3, 2020 at 20:10 Comment(1)
Very good hint! az ad signed-in-user show showed that my token has expired and I need to az login again.Bryanbryana
T
3

Run az login again, it's worked for me!

Topmast answered 18/5, 2021 at 7:53 Comment(0)
C
2

Although this answer is very similar to the others, the only thing that worked for my was to run:

$ az logout

Then:

$ az login

Just but running the login command, didn't seem to do anything. But by logging out I suspect it cleaned up any cache etc, then logging in after that worked.

Conductor answered 30/3, 2023 at 13:55 Comment(0)
C
1

I had this but the az ad signed-in-user show worked and the Azure CLI was up-to-date.

Terraform uses the command-line under-the-hood, but my terminal had additional lines injected in at the start (versioning, aliases/doskey), which is the bit that terraform was complaining about, rather than the Azure CLI. So I turned that off and it started working.

Ciaphus answered 30/9, 2021 at 15:22 Comment(0)
R
1

I had this issue as well. After looking through the link you provided, and trying various commands, including az logout and az login, it still was not working. az ad signed-in-user show did not show any errors or non-json output and my token was not expired, however when I ran az extension --help, I noticed a message that there was an update available for the azure cli.

So, what ended up working for me was to update the azure cli from 2.41.0 to 2.42.0. I did this via Homebrew, rather than the command given by the cli itself. Once I did that and then ran az login again, my terraform plan command worked without issues.

Rorry answered 5/11, 2022 at 15:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.