Terraform: Azurerm backend authentication with Azure CLI is not working when running Terraform init

Created on 16 Apr 2019  ยท  3Comments  ยท  Source: hashicorp/terraform

Terraform Version:
0.11.13

Terraform Template:

terraform {
    required_version = ">= 0.11.13"
    backend "azurerm" {
        resource_group_name = "<rg_name>"
        storage_account_name = "<account_name>"
        container_name       = "<container_name>"
        key                  = "test.terraform.tfstate"
    }
}

Azure CLI Version:
2.0.62

Command
terraform init

Error Message:

Error configuring the backend "azurerm": resource_group_name and credentials must be provided when access_key is absent

Please update the configuration in your Terraform files to fix this error
then run this command again.

Expected Behavior
Terraform init is successful and can use my Azure Credentials after running az login to setup Azure as the Backend store for state

Actual Behavior
terraform init errors with the above message and does not connect to backend or initialize TF

backenazure

Most helpful comment

@tombuildsstuff - Verified that the Service Principal works! Thanks for clarifying that it's a 0.12 feature.

All 3 comments

hi @raykao

Thanks for opening this issue.

Using the Azure CLI to authenticate with the Azure Backend is only supported in Terraform 0.12 and above, which is why you're seeing this error; in Terraform 0.11 you instead must specify either the Access Key for the Storage Account, or a Service Principal. Unfortunately due to the Terraform website not supporting multiple versions of the documentation at once this functionality went live before we planned it to - which makes this a little unclear.

At this time I'd recommend using a Service Principal with the Azure Backend - once Terraform 0.12 is released you should be able to switch over to using the Azure CLI to authenticate instead - would you be able to see if that works for you?

Thanks!

@tombuildsstuff - Verified that the Service Principal works! Thanks for clarifying that it's a 0.12 feature.

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.

Was this page helpful?
0 / 5 - 0 ratings