hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

azurerm backup valut #16567

Open mahi-linux opened 2 years ago

mahi-linux commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.1.6

AzureRM Provider Version

3.3.0

Affected Resource(s)/Data Source(s)

data "azurerm_backup_policy_vm" "policy" and resource "azurerm_backup_protected_vm"

Terraform Configuration Files

I've enrolled my test VM in azure backups using the below code, and when I destroy my test machine it's deleting all other VM backups. Either VM's are their backups are not even managed by terraform other than just one test machine. I'm I doing anything wrong here?

code:

#  terraform version
Terraform v1.1.6
on darwin_amd64
+ provider registry.terraform.io/hashicorp/azurerm v3.3.0

Your version of Terraform is out of date! The latest version
is 1.1.9. You can update by downloading from https://www.terraform.io/downloads.html

# cat modules/compute/main.tf

data "azurerm_backup_policy_vm" "policy" {
  name                = var.vm["backup_policy_name"]
  recovery_vault_name = var.vm["backup_vault_name"]
  resource_group_name = var.vm["backup_vault_resource_group"]
}

resource "azurerm_backup_protected_vm" "vm_protected_backup" {
  resource_group_name = data.azurerm_backup_policy_vm.policy.resource_group_name
  recovery_vault_name = data.azurerm_backup_policy_vm.policy.recovery_vault_name
  source_vm_id        = azurerm_linux_virtual_machine.vm.id
  backup_policy_id    = data.azurerm_backup_policy_vm.policy.id
}

Debug Output/Panic Output

# terraform destroy => Deleting vm1 and its associated resources.

module.subprod["vm1"].azurerm_backup_protected_vm.vm_protected_backup: Destroying... [id=/subscriptions/xxxx-xxx-xxxx-xxxx/resourceGroups/vault-rg/providers/Microsoft.RecoveryServices/vaults/vm-vault/backupFabrics/Azure/protectionContainers/IaasVMContainer;iaasvmcontainerv2;vm-rg;vm1/protectedItems/VM;iaasvmcontainerv2;vm-rg;vm1]
module.subprod["vm1"].azurerm_backup_protected_vm.vm_protected_backup: Still destroying... [id=/subscriptions/xxxx-xxx-xxxx-xxxx-...vm-rg;vm1, 10s elapsed]
module.subprod["vm1"].azurerm_backup_protected_vm.vm_protected_backup: Still destroying... [id=/subscriptions/xxxx-xxx-xxxx-xxxx-...vm-rg;vm1, 20s elapsed]
^CStopping operation...

Interrupt received.
Please wait for Terraform to exit or data loss may occur.
Gracefully shutting down...

╷
│ Error: waiting for the Azure Backup Protected VM "VM;iaasvmcontainerv2;vm-rg;vm1" to be false (Resource Group "vault-rg") to provision: context canceled
│

Expected Behaviour

No response

Actual Behaviour

No response

Steps to Reproduce

No response

Important Factoids

No response

References

No response

mahi-linux commented 2 years ago

Any update on this?