Terraform Azurerm 恢复服务 Vault 备份策略格式错误

Terraform Azurerm Recovery Services Vault Backup Policy Format Error

我正在尝试在 Terraform 到 运行 中创建每周 Azure VM 保护策略,周五 [=27] =] pm 保留为 1。TF 抛出与 'schedule time, schedule days, retention time and retention days' 错误相关的格式错误。我不确定哪个参数的值或格式不正确。

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 error(s) occurred:

  • azurerm_recovery_services_protection_policy_vm.backup_policy: Error creating/updating Recovery Service Protection Policy "Terraform-Linux-Test-RG-bkp-policy" (Resource Group "Terraform-Linux-Test-RG"): backup.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\r\nPlease check format of parameters like schedule time, schedule days, retention time and retention days "

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

谢谢 阿斯加尔

对于你的问题,可能是你犯了一个小错误。您只需要像这样在策略的备份块中进行更改:

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

然后就可以正常工作了。下面是我这边的测试截图: