Skip to content

Commit b507f5b

Browse files
committed
dataprotection - add data sources for backup policies
1 parent cc44961 commit b507f5b

20 files changed

+2146
-1
lines changed

examples/data-protection/main.tf

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Copyright IBM Corp. 2014, 2025
2+
# SPDX-License-Identifier: MPL-2.0
3+
4+
provider "azurerm" {
5+
features {}
6+
}
7+
8+
resource "azurerm_resource_group" "example" {
9+
name = "${var.prefix}-dataprotection-rg"
10+
location = var.location
11+
}
12+
13+
resource "azurerm_data_protection_backup_vault" "example" {
14+
name = "${var.prefix}-dataprotection-vault"
15+
resource_group_name = azurerm_resource_group.example.name
16+
location = azurerm_resource_group.example.location
17+
datastore_type = "VaultStore"
18+
redundancy = "LocallyRedundant"
19+
soft_delete = "Off"
20+
}
21+
22+
resource "azurerm_data_protection_backup_policy_blob_storage" "example" {
23+
name = "${var.prefix}-blob-policy"
24+
vault_id = azurerm_data_protection_backup_vault.example.id
25+
operational_default_retention_duration = "P30D"
26+
}
27+
28+
data "azurerm_data_protection_backup_policy_blob_storage" "example" {
29+
name = azurerm_data_protection_backup_policy_blob_storage.example.name
30+
vault_id = azurerm_data_protection_backup_vault.example.id
31+
}
32+
33+
resource "azurerm_data_protection_backup_policy_disk" "example" {
34+
name = "${var.prefix}-disk-policy"
35+
vault_id = azurerm_data_protection_backup_vault.example.id
36+
backup_repeating_time_intervals = ["R/2025-01-01T00:00:00+00:00/PT4H"]
37+
default_retention_duration = "P7D"
38+
}
39+
40+
data "azurerm_data_protection_backup_policy_disk" "example" {
41+
name = azurerm_data_protection_backup_policy_disk.example.name
42+
vault_id = azurerm_data_protection_backup_vault.example.id
43+
}
44+
45+
resource "azurerm_data_protection_backup_policy_kubernetes_cluster" "example" {
46+
name = "${var.prefix}-k8s-policy"
47+
resource_group_name = azurerm_resource_group.example.name
48+
vault_name = azurerm_data_protection_backup_vault.example.name
49+
50+
backup_repeating_time_intervals = ["R/2025-01-01T06:00:00+00:00/P1W"]
51+
52+
default_retention_rule {
53+
life_cycle {
54+
duration = "P7D"
55+
data_store_type = "OperationalStore"
56+
}
57+
}
58+
}
59+
60+
data "azurerm_data_protection_backup_policy_kubernetes_cluster" "example" {
61+
name = azurerm_data_protection_backup_policy_kubernetes_cluster.example.name
62+
vault_id = azurerm_data_protection_backup_vault.example.id
63+
}
64+
65+
resource "azurerm_data_protection_backup_policy_mysql_flexible_server" "example" {
66+
name = "${var.prefix}-mysql-policy"
67+
vault_id = azurerm_data_protection_backup_vault.example.id
68+
backup_repeating_time_intervals = ["R/2025-01-01T06:00:00+00:00/P1W"]
69+
70+
default_retention_rule {
71+
life_cycle {
72+
duration = "P4M"
73+
data_store_type = "VaultStore"
74+
}
75+
}
76+
}
77+
78+
data "azurerm_data_protection_backup_policy_mysql_flexible_server" "example" {
79+
name = azurerm_data_protection_backup_policy_mysql_flexible_server.example.name
80+
vault_id = azurerm_data_protection_backup_vault.example.id
81+
}
82+
83+
resource "azurerm_data_protection_backup_policy_postgresql_flexible_server" "example" {
84+
name = "${var.prefix}-psql-policy"
85+
vault_id = azurerm_data_protection_backup_vault.example.id
86+
backup_repeating_time_intervals = ["R/2025-01-01T06:00:00+00:00/P1W"]
87+
88+
default_retention_rule {
89+
life_cycle {
90+
duration = "P4M"
91+
data_store_type = "VaultStore"
92+
}
93+
}
94+
}
95+
96+
data "azurerm_data_protection_backup_policy_postgresql_flexible_server" "example" {
97+
name = azurerm_data_protection_backup_policy_postgresql_flexible_server.example.name
98+
vault_id = azurerm_data_protection_backup_vault.example.id
99+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright IBM Corp. 2014, 2025
2+
# SPDX-License-Identifier: MPL-2.0
3+
4+
output "blob_policy_id" {
5+
value = data.azurerm_data_protection_backup_policy_blob_storage.example.id
6+
}
7+
8+
output "disk_policy_id" {
9+
value = data.azurerm_data_protection_backup_policy_disk.example.id
10+
}
11+
12+
output "kubernetes_policy_id" {
13+
value = data.azurerm_data_protection_backup_policy_kubernetes_cluster.example.id
14+
}
15+
16+
output "mysql_flex_policy_id" {
17+
value = data.azurerm_data_protection_backup_policy_mysql_flexible_server.example.id
18+
}
19+
20+
output "psql_flex_policy_id" {
21+
value = data.azurerm_data_protection_backup_policy_postgresql_flexible_server.example.id
22+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright IBM Corp. 2014, 2025
2+
# SPDX-License-Identifier: MPL-2.0
3+
4+
variable "location" {
5+
type = string
6+
default = "Germany West Central"
7+
}
8+
9+
variable "prefix" {
10+
type = string
11+
default = "test"
12+
}

0 commit comments

Comments
 (0)