I upgraded my Terraform AzureRM provider from 1.44 to 2.23. Terraform version is 0.13.0. Interestingly now that I try to run terraform plan
I get multiple "Invalid resource instance data in state" errors.
They look like this:
Error: Invalid resource instance data in state
on .terraform\modules\redacted\terraform\modules\keyvault\main.tf line 1:
1: resource "azurerm_key_vault" "keyvault" {
Instance module.redacted.module.keyvault.azurerm_key_vault.keyvault data could
not be decoded from the state: unsupported attribute "sku".
My state file is in Azure storage. When looking into the state file we see the problem:
{
"module": "module.redacted.module.keyvault",
"mode": "managed",
"type": "azurerm_key_vault",
"name": "keyvault",
"provider": "module.redacted.provider.azurerm",
"instances": [
{
...
"sku": [
{
"name": "standard"
}
],
"sku_name": "standard",
....
The newest way to define the sku for keyvault is using the "sku_name" attribute. But the old way has stuck into the state file and is now causing problems.
What is the preferred way to upgrade the provider so that the state file is also cleared up? Or is this something that has to be done manually?