Azure - state file stored on storage container is not working

Hi,

I’m in upgrading mu modules to TF 12 and for some reason, the provider AzureRM stoped to store the state file remotely even after initializing the backend correctly.

I’m using the backend partial configuration, as I was using in TF 11, but after to plan and apply the state file is saved locally and I’m not able to use the TF outputs for the other automation because Jenkins remove the workspace.

Here is the part of the code and how I’m initializing the backend.

providers.tf

    terraform {
      required_providers {
        template = "~> 2.1.2"
        azurerm  = ">= 1.28"
      }
      required_version = ">= 0.12"
      backend "azurerm" {}
    }

and the command to initialize the TF using the backend file as parameter:

+ 0.12.0/terraform init -backend-config=westus/az-sandbox-01/s5-unixmanagedINT-rg-01/backend.config westus/az-sandbox-01/s5-unixmanagedINT-rg-01
Initializing modules...
Downloading git::ssh://git@github.XXXXX.com/dlrs/tf-azure-compute?ref=fjorg1_v0.12 for validation...
- validation in .terraform/modules/validation

Initializing the backend...

Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "azurerm" (terraform-providers/azurerm) 1.31.0...
[...]

Then, after applying I got the following message

**Apply complete! Resources: 5 added, 0 changed, 0 destroyed.** 
The state of your infrastructure has been saved to the path below. This state is required to modify and destroy your infrastructure, so keep it safe. To inspect the complete state use the `terraform show` command. 
State path: terraform.tfstate

What can be wrong? I’m using exactly the same backend configuration than I was used to use in TF 0.11

The weird part is that file is not even being created remotely on the storage container.

After some debug, I figured out that backend it’s not being used, for some reason which I have no idea why

Initializing the backend...
2019/07/17 15:28:04 [DEBUG] New state was assigned lineage "695b9f0d-03a7-3d7c-0882-e2e559438204"
2019/07/17 15:28:04 [DEBUG] checking for provider in "."
2019/07/17 15:28:04 [DEBUG] checking for provider in "/cust/app/jenkins/workspace/_validation_vm_fjorg1_v0.12-YM2NC7YH2ZZFQGHHSDG4OMF67YFYSO4NBGTQSN4V2E2MQOMSPEBQ/0.12.4"
2019/07/17 15:28:04 [DEBUG] checking for provisioner in "."
2019/07/17 15:28:04 [DEBUG] checking for provisioner in "/cust/app/jenkins/workspace/_validation_vm_fjorg1_v0.12-YM2NC7YH2ZZFQGHHSDG4OMF67YFYSO4NBGTQSN4V2E2MQOMSPEBQ/0.12.4"
2019/07/17 15:28:04 [INFO] Failed to read plugin lock file .terraform/plugins/linux_amd64/lock.json: open .terraform/plugins/linux_amd64/lock.json: no such file or directory
2019/07/17 15:28:04 [DEBUG] checking for provider in "."
2019/07/17 15:28:04 [DEBUG] checking for provider in "/cust/app/jenkins/workspace/_validation_vm_fjorg1_v0.12-YM2NC7YH2ZZFQGHHSDG4OMF67YFYSO4NBGTQSN4V2E2MQOMSPEBQ/0.12.4"

thank you in advance for any idea :slight_smile:

@flamarion

Check out my last post here --> Azure Backend Config

I was running into a similar issue and finally got it all working. Please let me know if you have any issues.