-
Notifications
You must be signed in to change notification settings - Fork 1
/
resources.tf
65 lines (57 loc) · 3.23 KB
/
resources.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
resource "azurerm_recovery_services_vault" "asr_vault" {
location = var.location
name = local.rsv_name
resource_group_name = var.resource_group_name
sku = "Standard"
tags = local.tags
}
resource "azurerm_site_recovery_fabric" "primary" {
name = local.primary_srf_name
location = var.primary_location
recovery_vault_name = azurerm_recovery_services_vault.asr_vault.name
resource_group_name = var.resource_group_name
}
resource "azurerm_site_recovery_fabric" "secondary" {
name = local.secondary_srf_name
location = var.location
recovery_vault_name = azurerm_recovery_services_vault.asr_vault.name
resource_group_name = var.resource_group_name
}
resource "azurerm_site_recovery_protection_container" "primary" {
name = local.primary_srpc_name
recovery_fabric_name = azurerm_site_recovery_fabric.primary.name
recovery_vault_name = azurerm_recovery_services_vault.asr_vault.name
resource_group_name = var.resource_group_name
}
resource "azurerm_site_recovery_protection_container" "secondary" {
name = local.secondary_srpc_name
recovery_fabric_name = azurerm_site_recovery_fabric.secondary.name
recovery_vault_name = azurerm_recovery_services_vault.asr_vault.name
resource_group_name = var.resource_group_name
}
resource "azurerm_site_recovery_network_mapping" "network_mapping" {
for_each = var.network_mapping
name = format("asr-netmapping-%s-to-%s", reverse(split("/", each.key))[0], reverse(split("/", each.value))[0])
recovery_vault_name = azurerm_recovery_services_vault.asr_vault.name
resource_group_name = var.resource_group_name
source_network_id = each.key
source_recovery_fabric_name = azurerm_site_recovery_fabric.primary.name
target_network_id = each.value
target_recovery_fabric_name = azurerm_site_recovery_fabric.secondary.name
}
resource "azurerm_site_recovery_protection_container_mapping" "container_mapping" {
name = "container-mapping"
resource_group_name = var.resource_group_name
recovery_vault_name = azurerm_recovery_services_vault.asr_vault.name
recovery_fabric_name = azurerm_site_recovery_fabric.primary.name
recovery_source_protection_container_name = azurerm_site_recovery_protection_container.primary.name
recovery_target_protection_container_id = azurerm_site_recovery_protection_container.secondary.id
recovery_replication_policy_id = azurerm_site_recovery_replication_policy.policy.id
}
resource "azurerm_site_recovery_replication_policy" "policy" {
name = var.replication_policy.name
resource_group_name = var.resource_group_name
recovery_vault_name = azurerm_recovery_services_vault.asr_vault.name
recovery_point_retention_in_minutes = var.replication_policy.recovery_point_retention_in_minutes
application_consistent_snapshot_frequency_in_minutes = var.replication_policy.application_consistent_snapshot_frequency_in_minutes
}