Skip to content
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

Modifying backup time in azurerm_backup_policy_vm fails #27444

Closed
1 task done
Greysi87 opened this issue Sep 20, 2024 · 0 comments · Fixed by #27448
Closed
1 task done

Modifying backup time in azurerm_backup_policy_vm fails #27444

Greysi87 opened this issue Sep 20, 2024 · 0 comments · Fixed by #27448

Comments

@Greysi87
Copy link

Greysi87 commented Sep 20, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.9

AzureRM Provider Version

3.116.0

Affected Resource(s)/Data Source(s)

azurerm_backup_policy_vm

Terraform Configuration Files

variable "timestamp-vm" {
  type        = string
  default     = "20:00"
}

variable "timezone" {
  type        = string
  default     = "W. Europe Standard Time"
}

variable "backup_resource_group_prefix" {
  type        = string
  default     = "rg-backup"
}

resource "azurerm_backup_policy_vm" "vm-gold-v2" {
  name                = "vm-gold-v2"
  resource_group_name = var.resource_group_name
  recovery_vault_name = azurerm_recovery_services_vault.rsv.name
  policy_type         = "V2"
  timezone            = var.timezone

  backup {
    frequency = "Daily"
    time      = var.timestamp-vm
  }
  instant_restore_retention_days = 3
  instant_restore_resource_group {
    prefix = var.backup_resource_group_prefix
  }

  retention_daily {
    count = 14
  }

  retention_weekly {
    count    = 4
    weekdays = ["Sunday"]
  }

  retention_monthly {
    count    = 12
    weekdays = ["Sunday"]
    weeks    = ["First"]
  }
}

Debug Output/Panic Output

Creating this policy works as expected. If I then change backup time to another time (e-g- from 20:00 to 21:00) and execute terraform apply, following planed change appears:

  ~ resource "azurerm_backup_policy_vm" "vm-gold-v2" {
        id                             = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-qua-chn-services-mgmt/providers/Microsoft.RecoveryServices/vaults/rsv-chn-services/backupPolicies/vm-gold-v2"
        name                           = "vm-gold-v2"
        # (5 unchanged attributes hidden)

      ~ backup {
          ~ time          = "20:00" -> "21:00"
            # (4 unchanged attributes hidden)
        }

        # (4 unchanged blocks hidden)
    }

If I approve this change, following error appears:
╷
│ Error: updating Backup Policy (Subscription: "00000000-0000-0000-0000-000000000000"
│ Resource Group Name: "rg-qua-chn-services-mgmt"
│ Vault Name: "rsv-chn-services"
│ Backup Policy Name: "vm-gold-v2"): protectionpolicies.ProtectionPoliciesClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BMSUserErrorInvalidPolicyInput" Message="Input for create or update policy is not in proper format. Please check format of parameters like schedule time, schedule days, retention time and retention days "
│
│   with azurerm_backup_policy_vm.vm-gold-v2,
│   on policy_vm.tf line 172, in resource "azurerm_backup_policy_vm" "vm-gold-v2":
│  172: resource "azurerm_backup_policy_vm" "vm-gold-v2" {
│
╵

Expected Behaviour

Backup time can be changed the same ways, as it can be set/created.

Actual Behaviour

If backup time should be changed, an error appears:


│ Error: updating Backup Policy (Subscription: "00000000-0000-0000-0000-000000000000"
│ Resource Group Name: "rg-qua-chn-services-mgmt"
│ Vault Name: "rsv-chn-services"
│ Backup Policy Name: "vm-gold-v2"): protectionpolicies.ProtectionPoliciesClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BMSUserErrorInvalidPolicyInput" Message="Input for create or update policy is not in proper format. Please check format of parameters like schedule time, schedule days, retention time and retention days "

│ with azurerm_backup_policy_vm.vm-gold-v2,
│ on policy_vm.tf line 172, in resource "azurerm_backup_policy_vm" "vm-gold-v2":
│ 172: resource "azurerm_backup_policy_vm" "vm-gold-v2" {

Initial creating backup policy for VMs works fine, only changes are affected.

Steps to Reproduce

  1. Define a VM backup policy (like example above) with backup {frequency = "Daily" time = "20:00" )
  2. Execute terraform apply to create this VM backup policy
  3. Change Backup Time (e.g. from "20:00" to "21:00"
  4. Execute terraform apply again and approve modification
    ==> Error happens.

Important Factoids

No response

References

This issue exists in azurerm version 3.112.0 to 4.2.0 (tested). probably also in previous versions (not tested).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant