35 lines
1.2 KiB
HCL
35 lines
1.2 KiB
HCL
# ------------------------------------------------------------------------------
|
|
# Amazon Backup
|
|
# ------------------------------------------------------------------------------
|
|
|
|
resource "aws_backup_vault" "this" {
|
|
name = var.vault_name
|
|
}
|
|
|
|
resource "aws_backup_plan" "this" {
|
|
name = var.plan_name
|
|
|
|
dynamic "rule" {
|
|
for_each = var.rules
|
|
|
|
content {
|
|
rule_name = lookup(rule.value, "name", null)
|
|
target_vault_name = lookup(rule.value, "target_vault_name", null)
|
|
schedule = lookup(rule.value, "schedule", null)
|
|
start_window = lookup(rule.value, "start_window", null)
|
|
completion_window = lookup(rule.value, "completion_window", null)
|
|
enable_continuous_backup = lookup(rule.value, "enable_continuous_backup", null)
|
|
|
|
dynamic "lifecycle" {
|
|
for_each = length(lookup(rule.value, "lifecycle", {})) == 0 ? [] : [lookup(rule.value, "lifecycle", {})]
|
|
content {
|
|
cold_storage_after = lookup(lifecycle.value, "cold_storage_after", 0)
|
|
delete_after = lookup(lifecycle.value, "delete_after", 90)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
depends_on = [aws_backup_vault.this]
|
|
}
|