Terraform Cloud store the state files in Azure storage account, When using Terraform Cloud, the default behaviour is indeed to store the state files within Terraform Cloud itself. However, we can override this behaviour by explicitly configuring a remote backend in my Terraform configuration files is that possible? I have tried to create the remote backend but it is not storing the file in storage account. Assist me to resolve this issue, Thanks in Advance!!
terraform {
backend "azurerm" {
resource_group_name = "Azure"
storage_account_name = "azuredevopsdev"
container_name = "terraformcloud"
key = "resourcegroup.tfstate"
}
}
To achieve this, you need to use a remote backend configuration in your Terraform files, as you've started doing.
However, if the state files are not being stored in the Azure storage account as expected, there might be issues with either the configuration or with permissions/access to the Azure storage account.
Here for demo purposes, I was trying to provision the resource group using Azure backend configuration which ended by storing the state file in the remote repository location i.e., in the storage account container we are looking for.
My demo terraform configuration:
Output:
Note: Make sure you are using the same user or SP that was used to create the storage account for the configuration in order to overcome the permission issues while accessing the storage account to store state files remotely. If not try to get relevant permissions on the storage account to have full access.