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