0

I have written some terraform code for the recovery service vault. It does not create the vault in Canada East and US West.

It gives the following error code:

azurerm_recovery_services_vault.backup_vault: Still creating... [1m30s elapsed]
╷
│ Error: creating Vault (Subscription: "****"
│ Resource Group Name: "mydev-rg"
│ Vault Name: "mydev-vault"): backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient#Update: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="UserErrorInvalidRequestParameter" Message="Parameter NO_PARAM in request is invalid. Please provide correct value for parameter NO_PARAM"
│ 
│   with azurerm_recovery_services_vault.backup_vault,
│   on main.tf line 22, in resource "azurerm_recovery_services_vault" "backup_vault":
│   22: resource "azurerm_recovery_services_vault" "backup_vault" {
│ 
╵

Below is my full terraform code.

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.40.0"
    }
  }
}

provider "azurerm" {
  features {}
  subscription_id = var.subscription_id
}

resource "azurerm_resource_group" "backup_vault" {
  name     = "mydev-rg"
  location = var.rg_location

}

# Create Azure Site Recovery Vault
resource "azurerm_recovery_services_vault" "backup_vault" {
  name                = "mydev-vault"
  location            = var.rg_location
  resource_group_name = azurerm_resource_group.backup_vault.name
  sku                 = "Standard"

  soft_delete_enabled = true

  public_network_access_enabled = false
  storage_mode_type             = "ZoneRedundant"

  depends_on = [
    azurerm_resource_group.backup_vault
  ]
}

#variables
variable "subscription_id" {
  type = string
}
variable "rg_location" {
  type = string
}

I managed to create the vault in different regions by equating var.rg_location with (eg. eastus, uksouth) except canadaeast and westus.

Martin
  • 1
  • 2

1 Answers1

0

I also got the same error when I tried in my environment previously.

enter image description here

The issue occurs with the storage_mode_type = "ZoneRedundant" setting. As explained in this Doc, you need to select it from the list of availability zones. And it is not supported for the recovery services vault. You can instead give it as a geo redundant. Geo redundancy functions similarly by protecting the site/vault from disasters and outages that affect a specific region.

I modified your code as below and was able to create the recovery services vault in Canada East as follows:

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.54.0"
    }
  }
}
provider "azurerm" {
  features {}
}
resource "azurerm_resource_group" "backup_vault" {
  name     = "mydev-rg"
  location = "CanadaEast"

}
resource "azurerm_recovery_services_vault" "vault" {
  name                = "mydev-vault"
  location            = azurerm_resource_group.backup_vault.location
  resource_group_name = azurerm_resource_group.backup_vault.name
  sku                 = "Standard"

  soft_delete_enabled = true
  depends_on = [
    azurerm_resource_group.backup_vault
  ]
}

Executed terraform init & validated the configuration with terraform validate:

enter image description here

Executed terraform plan:

enter image description here

Executed terraform apply:

enter image description here

Successfully deployed in Canada East region as shown:

enter image description here

Jahnavi
  • 3,076
  • 1
  • 3
  • 10