Error inspecting states in the "azurerm" backend: storage: service returned error: StatusCode=403, ErrorCode=AuthenticationFailed
I received below error while initializing Terraform with below command
terraform init -backend-config="access_key=$(az storage account keys list --resource-group "myresourcegroup" --account-name "mystorageaccountname" --query '[0].value' -o tsv)"
Issue:- I received below error while executing above terraform init command.
Terraform has detected that the configuration specified for the backend
has changed. Terraform will now check for existing state in the backends.
Error: Error inspecting states in the "azurerm" backend:
storage: service returned error: StatusCode=403, ErrorCode=AuthenticationFailed, ErrorMessage=Server failed to authenticate the request. Make
sure the value of Authorization header is formed correctly including the signature.
RequestId:1b4ff545-601e-0061-80d1-78ecf8000000
Time:2019-10-02T03:27:30.9633333Z, RequestInitiated=Wed, 02 Oct 2019 03:27:30 GMT, RequestId=1b4ff545-601e-0061-80d1-78ecf8000000, API Version=, QueryParameterName=, QueryParameterValue=
Prior to changing backends, Terraform inspects the source and destination
states to determine what kind of migration steps need to be taken, if any.
Terraform failed to load the states. The data in both the source and the
destination remain unmodified. Please resolve the above error and try again.
I have below execute.ps1 and backend.tf file under a demo folder which has terraform.exe too.
###################################backend.tf############################
terraform {
backend "azurerm" {
resource_group_name = "myresourcegroup"
storage_account_name = "mystorageaccountname"
container_name = "myterraformstate"
key = "myterraformstatefile"
}
}
###################################execute.ps1############################
az account set -s "Visual Studio Enterprise"
terraform init -backend-config="access_key=$(az storage account keys list --resource-group "myresourcegroup" --account-name "mystorageaccountname" --query '[0].value' -o tsv)"
Resolution:-
in order to resolve this issue, you go to your root folder and delete existing local .terraform folder and execute the execute.ps1 file again you will be able to initialize terraform succesfully.
Comments
Post a Comment