Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_recovery_services_vault - add limit on cross_region_restore_enabled #20406

Merged
merged 2 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ func resourceRecoveryServicesVault() *pluginsdk.Resource {
Default: true,
},
},

CustomizeDiff: pluginsdk.CustomDiffWithAll(
pluginsdk.ForceNewIfChange("cross_region_restore_enabled", func(ctx context.Context, old, new, meta interface{}) bool {
return old.(bool) && !new.(bool)
}),
),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,35 @@ func TestAccRecoveryServicesVault_basic(t *testing.T) {
})
}

func TestAccRecoveryServicesVault_basicWithCrossRegionRestore(t *testing.T) {
func TestAccRecoveryServicesVault_ToggleCrossRegionRestore(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_recovery_services_vault", "test")
r := RecoveryServicesVaultResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicWithCrossRegionRestore(data),
Config: r.basicWithCrossRegionRestore(data, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("cross_region_restore_enabled").HasValue("false"),
),
},
data.ImportStep(),
{
Config: r.basicWithCrossRegionRestore(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("cross_region_restore_enabled").HasValue("true"),
),
},
data.ImportStep(),
{
Config: r.basicWithCrossRegionRestore(data, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("cross_region_restore_enabled").HasValue("false"),
),
},
data.ImportStep(),
})
}

Expand Down Expand Up @@ -517,7 +533,7 @@ resource "azurerm_recovery_services_vault" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, enabled)
}

func (RecoveryServicesVaultResource) basicWithCrossRegionRestore(data acceptance.TestData) string {
func (RecoveryServicesVaultResource) basicWithCrossRegionRestore(data acceptance.TestData, enable bool) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand All @@ -534,11 +550,11 @@ resource "azurerm_recovery_services_vault" "test" {
resource_group_name = azurerm_resource_group.test.name
sku = "Standard"

cross_region_restore_enabled = true
cross_region_restore_enabled = %v

soft_delete_enabled = false
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, enable)
}

func (RecoveryServicesVaultResource) basicWithCrossRegionRestoreAndWrongStorageType(data acceptance.TestData) string {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/recovery_services_vault.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ The following arguments are supported:

* `cross_region_restore_enabled` - (Optional) Is cross region restore enabled for this Vault? Only can be `true`, when `storage_mode_type` is `GeoRedundant`. Defaults to `false`.

-> **Note:** Once `cross_region_restore_enabled` is set to `true`, changing it back to `false` forces a new Recovery Service Vault to be created.

* `soft_delete_enabled` - (Optional) Is soft delete enable for this Vault? Defaults to `true`.

* `encryption` - (Optional) An `encryption` block as defined below. Required with `identity`.
Expand Down