You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a storage account is removed from the Azure web portal terraform fails to handle the missing resource gracefully. This affects refresh, plan, and apply. It looks like terraform is trying to query information about storage containers inside the account before querying the account itself, so it doesn't realize that they will be gone as well.
Not being able to refresh the state files is a bit annoying though. Here are the workarounds I've found so far:
Go to the Azure portal and recreate enough resources manually to help Terraform find what it expects.
Just delete all your resource groups and re-deploy everything.
Edit the state file and remove the resources you think are gone from there.
Error refreshing state: 1 error(s) occurred:
* azurerm_storage_container.an_os_images: Error retrieving keys for storage account "anstoragestandard": autorest:DoErrorUnlessStatusCode 404 POST https://management.azure.com/subscriptions/3581893b-e014-4aab-820e-d84c7d38a77c/resourceGroups/AN_Prod/providers/Microsoft.Storage/storageAccounts/anstoragestandard/listKeys?api-version=2015-06-15 failed with 404 Not Found
Expected Behavior
If a storage account has been removed, why try to get state info for the files that were in the account?
I think it would be safe to mark them removed as well and update the state file.
Actual Behavior
Terraform fails here and does not update the state file.
Steps to Reproduce
Provision a storage account and a storage container inside the account.
Delete the storage account from the Azure portal
Run 'terraform refresh'
References
This may be appropriate to track along with issue #6526.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this issue - sorry it is happening. The error message that you are seeing is talking about a resource that isn't in the configuration sample you have provided. Can you check that you have the correct configuration in place (or should I assume that the config you have provided is a small sample of what you are using)?
Hey @stack72
Sorry about that, I copy and pasted the wrong storage config; I've updated the initial post with the right config.
What I suspect is happening is the refresh goes and tries to query state on azurerm_storage_container.an_os_images, but gets a 404 error because it relies on anstoragestandard from azurerm_storage_account.an_storage_std which was deleted in the Azure portal manually.
If it evaluated the storage account before the container it could realize that the resource is gone.
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.
ghost
locked and limited conversation to collaborators
Apr 25, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
If a storage account is removed from the Azure web portal terraform fails to handle the missing resource gracefully. This affects refresh, plan, and apply. It looks like terraform is trying to query information about storage containers inside the account before querying the account itself, so it doesn't realize that they will be gone as well.
Not being able to refresh the state files is a bit annoying though. Here are the workarounds I've found so far:
Terraform Version
0.6.15
Affected Resource(s)
Terraform Configuration Files
Debug Output
Expected Behavior
If a storage account has been removed, why try to get state info for the files that were in the account?
I think it would be safe to mark them removed as well and update the state file.
Actual Behavior
Terraform fails here and does not update the state file.
Steps to Reproduce
References
This may be appropriate to track along with issue #6526.
The text was updated successfully, but these errors were encountered: