Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 994
Karol Deland Avatar asked Mar 24 '20 20:03

Karol Deland


People also ask

What are the errors when trying to run terraform locally with azurerm?

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

What version of the azurerm provider should I upgrade to?

Prior to version 1.20, the AzureRM Provider used a different method of authorizing via the Azure CLI where credentials reset after an hour - as such, we'd recommend upgrading to version 1.20 or later of the AzureRM Provider.

Can terraform authenticate via the Azure CLI?

Terraform only supports authenticating using the az CLI (and this must be available on your PATH) - authenticating using the older azure CLI or PowerShell Cmdlets are not supported. Authenticating via the Azure CLI is only supported when using a User Account.

What are the common azuread client errors?

Error: building AzureAD Client: obtain subscription () from Azure CLI: Error parsing json result from the Azure CLI: Error waiting for the Azure CLI: exit status 1 As mentioned the error is not there when I log in locally with my own account with az login.


2 Answers

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!

like image 128
Karol Deland Avatar answered Nov 15 '22 08:11

Karol Deland


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

like image 37
June Ngo Avatar answered Nov 15 '22 09:11

June Ngo