New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing account_kind of azurerm_storage_account to StorageV2 causes destroy and create of storage account #5758
Comments
👍 |
now In provider, we could only mark a resource should be updated or recreated when a field changes, there is no way to dynamically change the behavior(update or recreate) |
So it is not possible to look at which property changed and decide whether a resource need to be re-created or can be updated? For no Azure TF resource? Does that mean if I e.g. change tags for a TF resource, it will be re-created? |
@MSSedusch Of course we can make resource update when a field changes. But in this case, if a user want to change the kind from "StorageV2" to "Storage", the update rest api will return error, thus result in another problem |
@njuCZ the idea is to change it from "Storage" to "StorageV2" which should be supported by the Azure Storage RP i.e. when you update from "Storage" to "StorageV2" using e.g. an ARM template, the update works and the data of the Storage Account is not removed. |
@MSSedusch to clarify here: Whilst it's possible to move between some SKU's to some other SKU's (e.g. I believe Standard -> StandardV2 off the top of my head), moving between others (e.g Standard -> Premium) requires recreating the Storage Account. Unfortunately with the way the Terraform Plugin SDK works today it's not possible to conditionally mark a field as ForceNew based on it's value (although that's planned) - as such for the moment we've opted to make this ForceNew, which will require recreation when this value changes. However I think may want investigating/re-evaluating to instead return an error during the update here (prompting the user to taint the resource) if the account types aren't migrateable. |
@tombuildsstuff thanks for the clarification. I think I understood the problem now.
That would work for us too :) |
Given that i don't want to trash my storagev1 accounts and their data to upgrade to v2, what is the terraform recommended way to achieve this upgrade? e.g. do i have to remove the storagev1 accounts from tfstate, update them in Azure portal etc, import them back into tfstate, then terraform plan? Having just had to do this for azurerm_recovery_services_protected_vm -> azurerm_backup_protected_vm and azurerm_recovery_services_protection_policy_vm -> azurerm_backup_policy_vm I'm somewhat frustrated at this point. This sort of thing really ought to be in the AzureRM v1.x to v2.x upgrade guide. |
Is there a roadmap for the way forward to migrate existing storage accounts from v1 to v2? |
Workaround I use is upgrade manually in Portal and the then terraform will
just do an update in place and add some extra properties to the state file
once you apply it.
…Sent from my mobile device
On Tue, Mar 31, 2020, 7:37 AM Claudia Baur ***@***.***> wrote:
Is there a roadmap for the way forward to migrate existing storage
accounts from v1 to v2?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#5758 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKK5KVB6GWULQTZB6JDK7LRKHIYLANCNFSM4KVJF7FQ>
.
|
@tombuildsstuff, we cannot upgrade manually as we have a bunch of landscapes running using older storage accounts which are distributed through the company. Please have a look at #6580 which was provided by Tobias. Thanks! |
This has been released in version 2.10.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 2.10.0"
}
# ... other configuration ... |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Community Note
Terraform (and AzureRM Provider) Version
Terraform v0.11.11
terraform-provider-azurerm_v1.40.0_x4
Affected Resource(s)
azurerm_storage_account
Terraform Configuration Files
Debug Output
https://gist.github.com/rosenkranzt/b60b10be835be27f0c29e7dc19e79c8c
Panic Output
Expected Behavior
When changing argument account_kind of Terraform ressource azurerm_storage_account from account_kind Storage (general purpose v1) to StorageV2 I expect an upgrade of the storage account as offered in the Azure portal.
Actual Behavior
A storage account gets destroyed and recreated.
This behaviour is described in the documentation.
Steps to Reproduce
Create a storage account of account_kind Storage.
Then change argument account_kind StorageV2.
Then run
Important Factoids
References
https://www.terraform.io/docs/providers/azurerm/r/storage_account.html
account_kind - (Optional) Defines the Kind of account. Valid options are BlobStorage, BlockBlobStorage, FileStorage, Storage and StorageV2. Changing this forces a new resource to be created. Defaults to Storage.
The text was updated successfully, but these errors were encountered: