Closed auwi987 closed 1 year ago
hi any updates on this one?
Hi @auwi987 , I've dug into this issue and I believe this is a very old tfstate right?
The panic stack was on migration.AccountV0ToV1.UpgradeFunc.func1
function, which means the Terraform was trying to upgrade your storage account resource's state in tfstate file from V0 to V1. azurerm_storage_account
resource is in schema version 2 now, and v1 was introduced in 2017/09/28 at this commit.
github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/migration.AccountV0ToV1.UpgradeFunc.func1({0x90?, 0xc0019915c0?}, 0x68a96d0?, {0x557c900?, 0xc000580400?})
github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/migration/account.go:21 +0x18c
The panic stack told us the panic was triggered by line 21:
func (AccountV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc {
return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
// this should have been applied from pre-0.12 migration system; backporting just in-case
LINE21: accountType := rawState["account_type"].(string)
split := strings.Split(accountType, "_")
rawState["account_tier"] = split[0]
rawState["account_replication_type"] = split[1]
return rawState, nil
}
}
The panic message panic: interface conversion: interface {} is nil, not string
means rawState["account_type"]
is nil
and cannot be converted into string
. Could you please check your tfstate file to see whether there's account_type
field in your storage account resource state? Since this argument in V0 is required I have no idea why we can get a nil
value. The argument schema in V0:
"account_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validateArmStorageAccountType,
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},
hi @lonegunmanb no account_type field
Sorry for the late reply @auwi987 , I've checked the azurerm_storage_account
git log, the account_replication_type
was introduced in commit 77d13c7608975a6c1a1ab4b8c9cedddd93557dda, and the schema version has been upgraded to V1 in the same commit.
In your state file we can see account_replication_type
but no account_type
, but the schema_version
is 0
, so my guess is this state file is corrupted by unknown reason, the schema_version
should be greater than 0
. Would you please tell us how do you get this state file? Thanks for your patience.
Hello @auwi987 , a kindly ping, how's things going?
Thanks for opening this issue. Since time has passed without a response regarding how your state file came to be, I am going to mark this issue as closed. If you are able to provide more information to help us reproduce this issue we may re-open this issue or open a new issue, thanks!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Is there an existing issue for this?
Community Note
Terraform Version
1.2.8
AzureRM Provider Version
3.20
Affected Resource(s)/Data Source(s)
azurerm
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
No response
Actual Behaviour
Steps to Reproduce
terraform plan
Important Factoids
No response
References
No response