Terraform - setup AzureRM as a backend storage


Say you're trying to setup terraforma backend - to save state file into Azure, you might get prompt asking for container name, then provide the configuration listed in figure 1.1.

Before that, you need to setup your ARM authentication (yes, all of this)

set ARM_CLIENT_ID=
set ARM_CLIENT_SECRET=
set ARM_SUBSCRIPTION_ID=
set ARM_TENANT_ID=

If you get error messages saying

"Error inspecting states in the "azurerm" backend" - please provide settings in figure 1.1

If you encounter this error, remember to delete your statefile folder (.terraform) or whenever any of your test results in failure. This is important

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.



If you want to pass DYNAMIC values in, you can use :-


terraform init -backend-config="container_name=devopstestingstate" -backend-config="key=sb.terraform.tfstate"  -backend-config="storage_account_name=terraformstate" -backend-config="access_key=your storage access key is required"


Your terraform should look something like this.

Figure 1.1.


terraform {
backend "azurerm"
{
container_name = "please provide a static name no variable allowed"
storage_account_name = "please provide a static name no variable allowed"
resource_group_name = "please provide"a static name no variable allowed"
key = "please provide a static name no variable allowed"
access_key = "please provide a static name - no variable allowed"
}
}




Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm