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.57k stars 4.62k forks source link

Support for Azure SQL Database Geo-Zone-Redundant Backup Storage #19542

Closed AErmie closed 7 months ago

AErmie commented 1 year ago

Is there an existing issue for this?

Community Note

Description

If you want to deploy an Azure SQL Database using Terraform, not all backup storage redundancy options are supported.

The options that are supported in the Azure Portal, include:

Azure-Portal-Backup-Storage-Redundancy

When you define the code block in Terraform for the azurerm_mssql_database resource, there is a property for storage_account_type (shown in the screenshot below).

Terraform-Code

However, the only supported types are geo, local, or zone, per the error shown by Terraform. Geo-Zone is not a supported account type, although it is an option in the portal.

Terraform-Plan-Error

Even though the azurerm_storage_account resource itself has a property for account_replication_type, which has valid options of: LRS, GRS, RAGRS, ZRS, GZRS and RAGZRS, you cannot use GZRS as a storage_account_type in the azurerm_mssql_database resource either.

It would be appreciated if the Azure Terraform Provider could be updated to support all properties and configurations for this Azure service.

Other Details

Terraform version: 0.15.5 AzureRM Provider version: 3.34.0

New or Affected Resource(s)/Data Source(s)

azurerm_mssql_database

Potential Terraform Configuration

resource "azurerm_mssql_database" "this" {
  storage_account_type    = "Geo-Zone"
}

References

gkello commented 1 year ago

That missing option is currently blocking me to provision HyperScale database with geo-redundant storage and zone_redundant = true: And it is not possible to adjust backup storage type after database creation for HyperScale tier.

resource azurerm_mssql_database "hyperscale" {
  name                  = "example-hyperscaledb"
  server_id             = azurerm_mssql_server.example.id
  sku_name              = "HS_Gen5_2"

  read_replica_count    = 1
  zone_redundant        = true
}

results with

Error: waiting for create/update of Database: (Name "example-hyperscaledb" / Server Name "example-mssqlserver" / Resource Group "example-database-rg"): Code="ProvisioningDisabled" Message="Provisioning of zone redundant Hyperscale database with geo backup redundancy is not supported. Zone redundant Hyperscale databases must use either zone or geo zone backup redundancy." with azurerm_mssql_database.hyperscale on hyperscaledb.tf line 24, in resource "azurerm_mssql_database" "hyperscale":

aparker-cityworks commented 1 year ago

This affects resource azurerm_mssql_managed_instance in the same way.

quaintance commented 1 year ago

does anyone have a workaround for this in the meantime? As far as I can tell, I cannot ignore this configuration in lifecycle management, we just can't manage anything about these DBs in Terraform.

MichalSino commented 1 year ago

Any changes about this ?

MichalSino commented 1 year ago

I found that API 23-02-01-preview supports: Local, Zone, Geo and GeoZone, so may be the provider shloud be updated to this Api version.

richsage commented 9 months ago

Looking at the code it looks like it already uses API 2023-02-01-preview, and there is a GeoZone storage option available - I haven't tested it but maybe this is already solved?

MichalSino commented 9 months ago

I confirmed it. It works now. :)

katbyte commented 7 months ago

this seems to have been fixed by #23721 - as such i am going to close it out!

github-actions[bot] commented 5 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.