Skip to content

Commit b692fcf

Browse files
Clarify docs and resolve tf warnings (#50)
* Update resource group parameters in usage documentation for clarity * Remove backend configuration for azurerm provider in main.tf * Fix dynamic block name for enabled metrics in backup vault diagnostic settings * Fix dynamic block name for backup vault metrics in diagnostic settings * Update azurerm provider version and fix dynamic block name for metrics in backup vault diagnostic settings * Update azurerm provider version and fix assertions in backup vault diagnostics tests
1 parent 30bc01f commit b692fcf

7 files changed

Lines changed: 36 additions & 38 deletions

File tree

docs/usage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ module "my_backup" {
128128

129129
| Name | Description | Required | Default |
130130
|------|-------------|-----------|---------|
131-
| `resource_group_name` | The name of the resource group that is created to contain the vault - this cannot be an existing resource group. | Yes | n/a |
132-
| `resource_group_location` | The location of the resource group that is created to contain the vault. | No | `uksouth` |
131+
| `resource_group_name` | The name of the resource group that is created to contain the vault - the resource group will be created if `create_resource_group` = true, and must be an existing resource group if `create_resource_group` = false. | Yes | n/a |
132+
| `resource_group_location` | The location of the resource group. | No | `uksouth` |
133133
| `create_resource_group` | States whether a resource group should be created. Setting this to `false` means the vault will be deployed into an externally managed resource group, the name of which is defined in `resource_group_name`. | No | `true` |
134134
| `backup_vault_name` | The name of the backup vault. The value supplied will be automatically prefixed with `rg-nhsbackup-`. If more than one az-backup module is created, this value must be unique across them. | Yes | n/a |
135135
| `backup_vault_redundancy` | The redundancy of the vault, e.g. `GeoRedundant`. [See the following link for the possible values.](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/data_protection_backup_vault#redundancy) | No | `LocallyRedundant` |

infrastructure/.terraform.lock.hcl

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infrastructure/backup_vault.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ resource "azurerm_monitor_diagnostic_setting" "backup_vault" {
3939
}
4040
}
4141

42-
dynamic "metric" {
42+
dynamic "enabled_metric" {
4343
for_each = toset(local.backup_vault_diagnostics_metric_categories)
4444
content {
45-
category = metric.key
45+
category = enabled_metric.key
4646
}
4747
}
4848
}

infrastructure/main.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@ terraform {
77
version = ">= 4.18.0, < 5.0"
88
}
99
}
10-
11-
backend "azurerm" {}
1210
}

tests/integration-tests/.terraform.lock.hcl

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration-tests/backup_vault.tftest.hcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ run "create_backup_vault" {
7171
])
7272
error_message = "Tags not as expected."
7373
}
74-
74+
7575
assert {
7676
condition = azurerm_data_protection_backup_vault.backup_vault.immutability == var.backup_vault_immutability
7777
error_message = "Backup vault immutability not as expected."
@@ -119,12 +119,12 @@ run "configure_vault_diagnostics_when_enabled" {
119119
}
120120

121121
assert {
122-
condition = length(azurerm_monitor_diagnostic_setting.backup_vault[0].metric) == length(local.backup_vault_diagnostics_metric_categories)
122+
condition = length(azurerm_monitor_diagnostic_setting.backup_vault[0].enabled_metric) == length(local.backup_vault_diagnostics_metric_categories)
123123
error_message = "Backup vault diagnostic setting metrics not as expected."
124124
}
125125

126126
assert {
127-
condition = alltrue([for metric in azurerm_monitor_diagnostic_setting.backup_vault[0].metric : contains(local.backup_vault_diagnostics_metric_categories, metric.category)])
127+
condition = alltrue([for metric in azurerm_monitor_diagnostic_setting.backup_vault[0].enabled_metric : contains(local.backup_vault_diagnostics_metric_categories, metric.category)])
128128
error_message = "Backup vault diagnostic setting metrics not as expected."
129129
}
130130
}

tests/integration-tests/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
azurerm = {
44
source = "hashicorp/azurerm"
5-
version = "4.18.0"
5+
version = ">= 4.18.0, < 5.0"
66
}
77
}
88
}

0 commit comments

Comments
 (0)