Open ksommoxy opened 2 years ago
Hello there!
Iยดm having a similar issue with azurerm_data_protection_backup_instance_blob_storage
azurerm_data_protection_backup_instance_blob_storage.sfo_backup_policy: Still creating... [2m20s elapsed]
โท
โ Error: waiting for BackupInstance("Backup Instance: (Name \"xxxx-xxxx-storage\" / Backup Vault Name \"xxxx-rvt-weu1-dev-000\" / Resource Group \"xxxx-xxxx-rsg-weu1-dev\")") policy protection to be completed: unexpected state 'ProtectionError', wanted target 'ProtectionConfigured'. last error: %!s(<nil>)
โ
โ with azurerm_data_protection_backup_instance_blob_storage.sfo_backup_policy,
โ on backup.tf line 37, in resource "azurerm_data_protection_backup_instance_blob_storage" "sfo_backup_policy":
โ 37: resource "azurerm_data_protection_backup_instance_blob_storage" "sfo_backup_policy" {
Terraform v1.1.9
on darwin_amd64
+ **provider registry.terraform.io/hashicorp/azurerm v3.16.0**
+ provider registry.terraform.io/hashicorp/external v2.1.0
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
Your version of Terraform is out of date! The latest version
is 1.2.6. You can update by downloading from https://www.terraform.io/downloads.html
If I run again, terraform said that the resource needs to be imported into the state.
โ Error: A resource with the ID "/subscriptions/xxxxxx-e132-4dcc-9044-62535fcc159f/resourceGroups/xxx-xxxx-rsg-weu1-dev/providers/Microsoft.DataProtection/backupVaults/xxxx-rvt-weu1-dev-000/backupInstances/xxxx-xxxx-storage" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_data_protection_backup_instance_blob_storage" for more information.
โ
โ with azurerm_data_protection_backup_instance_blob_storage.sfo_backup_policy,
โ on backup.tf line 37, in resource "azurerm_data_protection_backup_instance_blob_storage" "sfo_backup_policy":
โ 37: resource "azurerm_data_protection_backup_instance_blob_storage" "sfo_backup_policy" {
โ
And finally, if I re-run terraform it finishes OK.
@aasier : I suspect you have a different issue to ksommoxy, I recently ran into the same as yourself when my backup vault didn't have the Storage Account Backup Contributor role assigned to it's identity, this prevents the backup instance from being created successfully, may not be your exact issue but you're certainly getting different to the original post.
@ksommoxy : You don't list the role assignment for the backup vault in your post so might be something you're missing although I'm not sure that it will fix your issue.
Here is an example for applying the role assignment:
resource "azurerm_role_assignment" "example" {
scope = azurerm_storage_account.example.id
role_definition_name = "Storage Account Backup Contributor"
principal_id = azurerm_data_protection_backup_vault.example.identity[0].principal_id
}
Ran into this issue while applying an azurerm_data_protection_backup_instance_disk.
Terraform version 1.3.6 Azurerm Provider version 3.26.0
After running again the object seems to be in azure but no in the state, exact same error.
-edit- We traced it back to the system managed identity
I have the identical issue with provider version version = ">= 3.45.0" The role assigment worked. I can also not delete the backup vault from the gui, it errors with: Cannot delete the vault as there are existing instances or policies. They show up only after really a long time. Then I could delete them from the gui and rerun the failed terraform pipeline job. Did the second run, also fail.
This is the error:
Error: waiting for BackupInstance("Backup Instance (Subscription: \"XXX\"\nResource Group Name: \"XXX\"\nBackup Vault Name: \"XXX\"\nBackup Instance Name: \"XXX\")") policy protection to be completed: unexpected state 'ProtectionError', wanted target 'ProtectionConfigured'. last error: %!s(<nil>)
I'm hitting this error as well, on 3.46.0, when trying to enable backup on a storage account. From the GUI the "fix protection error" doesn't work, though attempting to delete the instance works the second time in the GUI.
Fwiw, I do have HNS enabled on the storage account.
@atombravo Did you figure this one out? I am struggling with the exact same issue. I am currently on v3.84 and the issue is still present. Going to try updating to v3.89 to see if it is still present..
Edit 1: Updating to v.3.89 did not fix it
Edit 2: If anyone else are having issues, here's the fix:
As shown in the documentation for azurerm here, you'll need to add a role assignment for the system managed identity on the backup vault and give it the role Storage Account Backup Contributor
on the storage account.
resource "azurerm_role_assignment" "example" {
scope = azurerm_storage_account.example.id
role_definition_name = "Storage Account Backup Contributor"
principal_id = azurerm_data_protection_backup_vault.example.identity[0].principal_id
}
@atombravo I have the same issue but it seems like the HNS enabled storage accounts are not supported. https://learn.microsoft.com/en-us/azure/backup/blob-backup-support-matrix?tabs=vaulted-backup#limitations
Community Note
Terraform (and AzureRM Provider) Version
Terraform v1.1.7
Affected Resource(s)
azurerm_data_protection_backup_instance_blob_storage
Terraform Configuration Files
Debug Output
Panic Output
N/A
Expected Behaviour
Apply returns successfully without error.
Actual Behaviour
The backup instance is created within the Vault, but an error is thrown when waiting/querying to verify the creation of the backup instance.
Steps to Reproduce
terraform apply
Important Factoids
Backup Contributor
role on the Backup Vault's resource groupMicrosoft.DataProtection/locations/operationStatus/read
permissionBackup Reader
(which contains the operation status read permission) at the subscription level/scope allows the configuration to be applied successfully.References