Skip to content

Commit 1db99a3

Browse files
authored
Merge pull request #3 from schubergphilis/fix_count_issue
bug: fix for computed problem that it cannot use an cmk for encryption because that will only know after apply, hence put a variable in between
2 parents bd058ed + 1877058 commit 1db99a3

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ No modules.
2929

3030
| Name | Description | Type | Default | Required |
3131
|------|-------------|------|---------|:--------:|
32-
| <a name="input_backup_vault"></a> [backup\_vault](#input\_backup\_vault) | n/a | <pre>object({<br> name = string<br> location = string<br> redundancy = string<br> immutability = string // accepted values are "Disabled"", "Locked", "Unlocked" <br> soft_delete_retention_days = number<br> cmk_key_vault_key_id = optional(string, null)<br> })</pre> | n/a | yes |
32+
| <a name="input_backup_vault"></a> [backup\_vault](#input\_backup\_vault) | n/a | <pre>object({<br> name = string<br> location = string<br> redundancy = string<br> immutability = string // accepted values are "Disabled"", "Locked", "Unlocked"<br> soft_delete_retention_days = number<br> cmk_key_vault_key_id = optional(string, null)<br> })</pre> | n/a | yes |
3333
| <a name="input_blob_storage_backup_policy"></a> [blob\_storage\_backup\_policy](#input\_blob\_storage\_backup\_policy) | n/a | <pre>map(object({<br> retention_duration = string<br> backup_repeating_time_intervals = list(string) // example ["R/2025-02-21T14:00:00+00:00/P1D"]<br> }))</pre> | n/a | yes |
3434
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | The name of the resource group in which the Recovery Services Vault should be created. | `string` | n/a | yes |
35+
| <a name="input_enable_customer_managed_key"></a> [enable\_customer\_managed\_key](#input\_enable\_customer\_managed\_key) | Whether to enable customer managed key for the backup vault. | `bool` | `false` | no |
3536
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |
3637

3738
## Outputs

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ resource "azurerm_data_protection_backup_vault" "this" {
2121
}
2222

2323
resource "azurerm_data_protection_backup_vault_customer_managed_key" "this" {
24-
count = var.backup_vault.cmk_key_vault_key_id != null ? 1 : 0
24+
count = var.enable_customer_managed_key ? 1 : 0
2525
data_protection_backup_vault_id = azurerm_data_protection_backup_vault.this.id
2626
key_vault_key_id = var.backup_vault.cmk_key_vault_key_id
2727
}

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ variable "backup_vault" {
1414
name = string
1515
location = string
1616
redundancy = string
17-
immutability = string // accepted values are "Disabled"", "Locked", "Unlocked"
17+
immutability = string // accepted values are "Disabled"", "Locked", "Unlocked"
1818
soft_delete_retention_days = number
1919
cmk_key_vault_key_id = optional(string, null)
2020
})
2121
}
2222

23+
variable "enable_customer_managed_key" {
24+
type = bool
25+
description = "Whether to enable customer managed key for the backup vault."
26+
default = false
27+
}
28+
2329
variable "blob_storage_backup_policy" {
2430
type = map(object({
2531
retention_duration = string

0 commit comments

Comments
 (0)