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.52k stars 4.6k forks source link

azurerm_backup_protected_vm - allow source_vm_id as list #26874

Open louisleesap opened 1 month ago

louisleesap commented 1 month ago

Is there an existing issue for this?

Community Note

Description

Currently the azurerm_backup_protected_vm module processes each vm_id separately requiring a for loop to be used when creating backups for multiple Virtual Machines. This generates a large number of API requests. In some environments this may trigger ResourceRequestsThrottled errors where the limit is exceeded.

See Error message below:

{
    'error': {
        'code': 'ResourceRequestsThrottled',
        'message': 'Number of requests for action 'Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems/read' exceeded the
limit of '150' for time interval '01:00:00'. Please try again after '324' seconds.'
    }
}

New or Affected Resource(s)/Data Source(s)

azurerm_backup_protected_vm

Potential Terraform Configuration

locals {
  vm_list = []
}

resource "azurerm_backup_protected_vm" "instance_list" {
  resource_group_name = local.resource_group_name
  recovery_vault_name = local.recovery_vault_name
  backup_policy_id    = local.backup_policy_id
  source_vm_id        = local.vm_list
}

References

No response

sinbai commented 1 month ago

Hi @louisleesap thanks for opening this issue. I would like to confirm whether this issue expects the property source_vm_id to support setting multiple vm ids? If so, I assume that this is not in line with the design principles of Terraform. Terraform relies on the Azure Rest API to implement CRUD management of Azure resources. In Azure Rest API, the virtualMachineId corresponding to source_vm_id only support the setting of a single vm id.

Regarding the ResourceRequestsThrottled issue, I'm assuming this is a Terraform usage issue. Given that this forum is intended to be used for feature enhancements and bugs in the Azure Provider . So that we can keep this forum focused on that we instead ask that questions are raised using one of the Community Resources.

Thanks!