github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/examples/azure/terraform-azure-recoveryservices-example/main.tf (about) 1 # --------------------------------------------------------------------------------------------------------------------- 2 # DEPLOY AN AZURE AVAILABILITY SET 3 # This is an example of how to deploy an Azure Availability Set with a Virtual Machine in the availability set 4 # and the minimum network resources for the VM. 5 # --------------------------------------------------------------------------------------------------------------------- 6 # See test/azure/terraform_azure_availabilityset_example_test.go for how to write automated tests for this code. 7 # --------------------------------------------------------------------------------------------------------------------- 8 9 provider "azurerm" { 10 version = "~> 2.20" 11 features {} 12 } 13 14 terraform { 15 # This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting 16 # 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it 17 # forwards compatible with 0.13.x code. 18 required_version = ">= 0.12.26" 19 } 20 21 # --------------------------------------------------------------------------------------------------------------------- 22 # DEPLOY A RESOURCE GROUP 23 # --------------------------------------------------------------------------------------------------------------------- 24 25 resource "azurerm_resource_group" "resource_group" { 26 name = "terratest-ars-rg-${var.postfix}" 27 location = var.location 28 } 29 30 # --------------------------------------------------------------------------------------------------------------------- 31 # DEPLOY A RECOVERY SERVICES VAULT 32 # --------------------------------------------------------------------------------------------------------------------- 33 34 resource "azurerm_recovery_services_vault" "vault" { 35 name = "rsvault${var.postfix}" 36 location = azurerm_resource_group.resource_group.location 37 resource_group_name = azurerm_resource_group.resource_group.name 38 sku = "Standard" 39 } 40 41 # --------------------------------------------------------------------------------------------------------------------- 42 # DEPLOY A BACKUP POLICY 43 # --------------------------------------------------------------------------------------------------------------------- 44 45 resource "azurerm_backup_policy_vm" "vm_policy" { 46 name = "vmpolicy-${var.postfix}" 47 resource_group_name = azurerm_resource_group.resource_group.name 48 recovery_vault_name = azurerm_recovery_services_vault.vault.name 49 50 timezone = "UTC" 51 52 backup { 53 frequency = "Daily" 54 time = "23:00" 55 } 56 57 retention_daily { 58 count = 10 59 } 60 61 retention_weekly { 62 count = 42 63 weekdays = ["Sunday", "Wednesday", "Friday", "Saturday"] 64 } 65 66 retention_monthly { 67 count = 7 68 weekdays = ["Sunday", "Wednesday"] 69 weeks = ["First", "Last"] 70 } 71 72 retention_yearly { 73 count = 77 74 weekdays = ["Sunday"] 75 weeks = ["Last"] 76 months = ["January"] 77 } 78 }