hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.53k stars 4.6k forks source link

Changing geo_redundant_backup_enabled for azurerm_mysql_server is not allowed by azure after creation. #13223

Open hatvik opened 3 years ago

hatvik commented 3 years ago

Community Note

Terraform (and AzureRM Provider) Version

Affected Resource(s)

Terraform Configuration Files

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mariadb_server#example-usage

Expected Behaviour

   module.test.azurerm_mysql_server.this[0] will be updated in-place
  ~ resource "azurerm_mysql_server" "this" {
      ~ geo_redundant_backup_enabled      = false -> true
        id                                = "/subscriptions/xxxxx/resourceGroups/test-tfazdb-yj0nr/providers/Microsoft.DBforMySQL/servers/testtfazdbyj0nr01"
        name                              = "testtfazdbyj0nr01"
        tags                              = {}
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Actual Behaviour

Error: updating Server: (Name "testtfazdbyj0nr01" / Resource Group "test-tfazdb-yj0nr"): mysql.ServersClient#Update: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="UnsupportedUpdate" Message="Cannot update GeoRedundantBackup for server"

Steps to Reproduce

  1. Create mysql or maria server with geo_redundant_backup_enabled=false
  2. Change geo_redundant_backup_enabled to true
  3. Apply again

Important Factoids

References

Configuring locally redundant or geo-redundant storage for backup is only allowed during server create. Once the server is provisioned, you cannot change the backup storage redundancy option. In order to move your backup storage from locally redundant storage to geo-redundant storage, creating a new server and migrating the data using dump and restore is the only supported option

mahalel commented 2 years ago

I can confirm the behaviour as well. Expect for it to be recreated but I just get this error:

module.maria_db.azurerm_mariadb_server.moodle: Modifying... [id=/subscriptions/<REDACTED>/resourceGroups/ae-prod-rg-moodle/providers/Microsoft.DBforMariaDB/servers/ae-prod-maria-moodle-xxx]

Error: updating Server: (Name "ae-prod-maria-moodle-xxx" / Resource Group "ae-prod-rg-moodle"): mariadb.ServersClient#Update: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="UnsupportedUpdate" Message="Cannot update GeoRedundantBackup for server"

  with module.maria_db.azurerm_mariadb_server.moodle,
  on moodle/maria_db/main.tf line 43, in resource "azurerm_mariadb_server" "moodle":
  43: resource "azurerm_mariadb_server" "moodle" {