can we specify for_each in the terraform resource called resource “azurerm_site_recovery_replication_recovery_plan”?
Trying to create a recovery plan for a single replicated item with 2 post actions however it is trying to create two seperate recovery plans for each of the automation runbook. and hence failing terraform apply.
here is my code below:
resource “azurerm_site_recovery_replication_recovery_plan” “samtest” {
for_each = {
for runbook in local.runbookId : “{runbook.VmId}.{runbook.runbookId}” => runbook
}
name = “recovery-plan-samtest”
recovery_vault_id = azurerm_recovery_services_vault.dr-vault.id
source_recovery_fabric_id = azurerm_site_recovery_fabric.primary.id
target_recovery_fabric_id = azurerm_site_recovery_fabric.secondary.id
recovery_group {
type = “Boot”
replicated_protected_items = [azurerm_site_recovery_replicated_vm.vm-replication[each.value.VmId].id]
post_action {
name = “Runbooks”
type = “AutomationRunbookActionDetails”
fail_over_directions = [“PrimaryToRecovery”]
fail_over_types = [“TestFailover”]
fabric_location = “Primary”
runbook_id = azurerm_automation_runbook.automated-test-script[each.key].id
}
}
recovery_group {
type = “Shutdown”
}
recovery_group {
type = “Failover”
}
}