Terraform Azurerm azurerm_recovery_services_protected_vm“设置即时恢复快照的数量”

时间:2019-05-13 18:56:12

标签: azure backup terraform snapshot recovery

我已经使用Terraform成功创建了每日和每周备份策略,并且都可以正常工作。但是,Azure门户在策略刀片上的“即时还原”下显示一个红色标记,表示“保留即时恢复快照”,并且该值显示为2天。我需要将此值更改为5;但是,我看不到在Terraform中进行更改的选项。我想知道是否应该使用“ azurerm_snapshot”资源类型进行更改,或者在TF中是否有解决方法。

resource "azurerm_recovery_services_protection_policy_vm" "backup_policy_weekly" {
  name                = "${var.RG4VM}-weekly-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"]
   timezone            = "UTC"

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

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

  retention_monthly {
    count    = "1"
    weekdays = ["Friday"]
    weeks    = ["Last"]
  }
}

预期:快照设置为5,因为它是最小值 实际:2

谢谢你/阿斯加尔

1 个答案:

答案 0 :(得分:0)

对于您的问题,我只能说Terraform不支持​​该属性。您可以在Azure REST API for Recovery Policy中将其作为属性instantRpRetentionRangeInDays进行查看,并使用如下的请求正文:

{
  "properties": {
    "backupManagementType": "AzureIaasVM",
    "schedulePolicy": {
      "schedulePolicyType": "SimpleSchedulePolicy",
      "scheduleRunFrequency": "Weekly",
      "scheduleRunDays": [
        "Friday"
      ],
      "scheduleRunTimes": [
        "2018-07-30T18:30:00Z"
      ],
      "scheduleWeeklyFrequency": 0
    },
    "retentionPolicy": {
      "retentionPolicyType": "LongTermRetentionPolicy",
      "weeklySchedule": {
        "daysOfTheWeek": [
          "Friday"
        ],
        "retentionTimes": [
          "2018-07-30T18:30:00Z"
        ],
        "retentionDuration": {
          "count": 5,
          "durationType": "Weeks"
        }
      }
    },
    "instantRpRetentionRangeInDays": 5,
    "timeZone": "UTC",
    "protectedItemsCount": 0
  }
}

或者您也可以使用Azure Template并在其中显示。但是您无法在Terraform中找到该属性。因此,我建议您可以使用Azure REST API或模板来实现它。