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_mssql_database: unexpected status 400 (400 Bad Request) with error: FeatureIsNotAvailableForServiceTier: Updating property DiffBackupIntervalInHours is not available for Hyperscale service tier. #25991

Open
1 task done
darren-hexagon opened this issue May 16, 2024 · 0 comments
Labels
service/mssql Microsoft SQL Server v/3.x

Comments

@darren-hexagon
Copy link

darren-hexagon commented May 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.8.3

AzureRM Provider Version

3.102.0

Affected Resource(s)/Data Source(s)

azurerm_mssql_database

Terraform Configuration Files

resource "azurerm_mssql_database" "example-db" {
  server_id                   = data.azurerm_mssql_server.clipper-aks-amssql-server.id
  name                        = local.tenant_db_name
  collation                   = var.tenant_db_collation
  auto_pause_delay_in_minutes = var.tenant_db_auto_pause_delay_in_minutes
  min_capacity                = var.tenant_db_min_capacity
  max_size_gb                 = var.tenant_db_max_size_gb != 0 ? var.tenant_db_max_size_gb : null # if max_size_gb is 0 then this is a Hyperscale tier
  sku_name                    = var.tenant_db_sku_name
  read_scale                  = var.tenant_db_read_scale
  zone_redundant              = var.tenant_db_zone_redundant
  geo_backup_enabled          = var.tenant_db_geo_backup_enabled
  storage_account_type        = var.tenant_db_storage_account_type != "" ? var.tenant_db_storage_account_type : null
  elastic_pool_id             = var.elastic_pool_id != "" ? var.elastic_pool_id : null

  lifecycle {
    ignore_changes = [ 
      auto_pause_delay_in_minutes, 
      min_capacity, 
      short_term_retention_policy.0.retention_days, 
      short_term_retention_policy.0.backup_interval_in_hours
    ]
  }

  dynamic "short_term_retention_policy" {
    for_each = var.tenant_db_max_size_gb != 0 ? ["ElasticPool"] : []
    content {
      backup_interval_in_hours = var.tenant_backup_interval_in_hours
      retention_days = var.tenant_db_retention_days
    }
  }

  dynamic "short_term_retention_policy" {
    for_each = var.tenant_db_max_size_gb == 0 ? ["Hyperscale"] : []
    content {
      retention_days = var.tenant_db_retention_days
    }
  }

  tags = local.tags
}

Debug Output/Panic Output

╷
│ Error: setting Short Term Retention Policies for Database (Subscription: "aaaaaaaaaaaaa"
│ Resource Group Name: "cl-aks-we-sbx-rg"
│ Server Name: "example_server_name"
│ Database Name: "dsmithtesttenantdb_10"): performing CreateOrUpdate: unexpected status 400 (400 Bad Request) with error: FeatureIsNotAvailableForServiceTier: Updating property DiffBackupIntervalInHours is not available for Hyperscale service tier.
│
│   with module.clipper_mt_tenant["dsmithtesttenantdb_10"].azurerm_mssql_database.example-db,
│   on .terraform/modules/clipper_mt_tenant/ClipperMtMain.tf line 34, in resource "azurerm_mssql_database" "example-db":
│   34: resource "azurerm_mssql_database" "example-db" {
│
╵
Operation failed: failed running terraform apply (exit 1)

Expected Behaviour

When creating a database in a Hyperscale tier elastic pool the short_term_retention_policy dynamic block for Hyperscale should only set the retention_days policy because backup_interval_in_hours does not exist on a Hyperscale tier elastic pool.
When using v3.83.0 of the provider this dynamic block worked and the database was successfully created in a hyperscale elastic pool.

When updating a database we shouldn't need a lifecycle ignore_changes block for both retention_days and backup_interval_in_hours. If we don't ignore_changes for these then the above error is thrown. Going forward, we do not want to ignore these policies because we want to be able to update them.

Actual Behaviour

Since uplifting to v3.102.0 of the provider the above error is always thrown when trying to create a database in a hyperscale tier elastic pool. However, the database appears to be successfully created in the hyperscale elastic pool in Azure, despite the Terraform error.

If we do not use a lifecycle ignore_changes block for both retention_days and backup_interval_in_hours policies the above error is always thrown when updating a database in a hyperscale tier elastic pool. This was also an issue in v3.83.0.

Steps to Reproduce

No response

Important Factoids

No response

References

No response

@github-actions github-actions bot added service/mssql Microsoft SQL Server v/3.x labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service/mssql Microsoft SQL Server v/3.x
Projects
None yet
Development

No branches or pull requests

1 participant