I am running terraform azurerm backup tests and running into an odd syntax issue. I am starting with the hashicorp documented example and changing the time but azure comes back with an error: "Message="Parameter NO_PARAM in request is invalid."
hashicorp example: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/backup_policy_vm
Error:
│ Error: updating Backup Policy (Subscription: "xxxxxx-xxxx-xxxx-xxxxxxxxxx"
│ Resource Group Name: "vm-backup-test"
│ Vault Name: "backup-test-vault"
│ Backup Policy Name: "backup-test-vault-policy"): protectionpolicies.ProtectionPoliciesClient#CreateOrUpdate: 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"
Here is the terraform. Aside from editing the resource group and recovery vault name, and changing the version to v2 (enhanced) this is an exact copy of the documented example from hashicorp:
If I change the time to anything other than 23:00, the error will generate. If I change any other details, such as timezone to America/New_York, it will error. The only parameters that will work are the ones shown below.
I have tried both with updating the policy, and with testing on a fresh deployment. In every case, if any parameters are even slightly changed (such as time from 23:00 to 22:00 or 23:30), it will error.
I have researched and tested repeatedly but not finding any resolution. Is there some trick to get this working? Or is there an issue/bug with azurerm 4.0+?
Is there any logging/debugging on the backup vault that would help narrow down the error for more granular tracing? In terraform trace debug it only shows the http 400 error but no further explanation or details for the cause of the error.
Currently I am testing on azurerm provider 4.2.2. provider details are below.
resource "azurerm_backup_policy_vm" "backup_test_policy" {
name = "backup-test-vault-policy"
resource_group_name = var.resource_group_name
recovery_vault_name = azurerm_recovery_services_vault.backup_test_vault.name
policy_type = "V2"
timezone = "UTC"
backup {
frequency = "Daily"
time = "23:00"
}
retention_daily {
count = 10
}
retention_weekly {
count = 42
weekdays = ["Sunday", "Wednesday", "Friday", "Saturday"]
}
retention_monthly {
count = 7
weekdays = ["Sunday", "Wednesday"]
weeks = ["First", "Last"]
}
retention_yearly {
count = 77
weekdays = ["Sunday"]
weeks = ["Last"]
months = ["January"]
}
}
terraform {
required_providers {
azapi = {
source = "azure/azapi"
version = "~> 1.8"
}
azurerm = {
source = "hashicorp/azurerm"
version = "~> 4.0"
}
}
}
provider "azapi" {
default_location = "eastus"
}
provider "azurerm" {
subscription_id = var.subscription_id
features {}
}