Terraform Azurerm恢复服务保管库备份策略格式错误

时间:2019-05-10 19:36:38

标签: azure backup terraform recovery

我正尝试在 Terraform 中创建每周一次的 Azure VM 保护策略,使其在星期五下午6:30运行,保留时间为1。TF引发与格式错误有关的内容出现“计划时间,计划天数,保留时间和保留天数”错误我不确定哪个参数的值或格式不正确。

resource "azurerm_recovery_services_vault" "backup_vault" {
  name                = "${var.RG4VM}-recovery-vault"
  location            = "${var.VMLocation}"
  resource_group_name = "${var.RG4VM}"
  sku                 = "Standard"
  depends_on          = ["azurerm_resource_group.ResourceGroup"]
}

resource "azurerm_recovery_services_protection_policy_vm" "backup_policy" {
  name                = "${var.RG4VM}-bkp-policy"
  resource_group_name = "${var.RG4VM}"
  recovery_vault_name = "${azurerm_recovery_services_vault.backup_vault.name}"
  depends_on          = ["azurerm_recovery_services_vault.backup_vault"]

  backup {
    frequency = "Weekly"
    time      = "18:30"
  }

  retention_weekly {
    count    = 1
    weekdays = ["Friday"]
  }
} 

预期: 它应该根据定义的配置创建策略。

实际:

  
      
  • azurerm_recovery_services_protection_policy_vm.backup_policy:发生1个错误:

  •   
  • azurerm_recovery_services_protection_policy_vm.backup_policy:创建/更新恢复服务保护策略时出错   “ Terraform-Linux-Test-RG-bkp策略”(资源组   “ Terraform-Linux-Test-RG”):   backup.ProtectionPoliciesClient#CreateOrUpdate:响应失败   要求:StatusCode = 400-原始错误:autorest / azure:服务   返回错误。 Status = 400代码=“ BMSUserErrorInvalidPolicyInput”   Message =“创建或更新策略的输入不正确   格式\ r \ n请检查诸如时间表时间,   计划天数,保留时间和保留天数“

  •   

对于解决此问题的任何帮助,我们将不胜感激。

谢谢 阿斯哈尔

1 个答案:

答案 0 :(得分:0)

对于您的问题,也许您犯了一个小错误。您只需要像下面这样更改策略的备份块:

backup {
    frequency = "Weekly"
    time      = "18:30"
    weekdays  = ["Friday"]
  }

然后它将正常工作。下面是我这一边的测试屏幕截图:

enter image description here