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 does not allow to set backup_interval_in_hours to 0 for hyperscale DBs #27716

Open
1 task done
fotto opened this issue Oct 21, 2024 · 3 comments
Open
1 task done

Comments

@fotto
Copy link

fotto commented Oct 21, 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 comments along the lines of "+1", "me too" or "any updates", 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.9.8

AzureRM Provider Version

4.6.0

Affected Resource(s)/Data Source(s)

azurerm_mssql_database

Terraform Configuration Files

resource "azurerm_mssql_database" "this" {
  name      = var.name
  server_id = var.server_id

  sku_name = "HS_S_Gen5_2"

  ...

  short_term_retention_policy {
    retention_days           = 7
    backup_interval_in_hours = 0 # <== only 12 or 24 are accepted
  }

Debug Output/Panic Output

╷
│ Error: expected short_term_retention_policy.0.backup_interval_in_hours to be one of [12 24], got 0
│ 
│   with module.pur_mssql_db[0].azurerm_mssql_database.this,
│   on .terraform/modules/pur_mssql_db/mssql_db_hs_s/main.tf line 20, in resource "azurerm_mssql_database" "this":
│   20:     backup_interval_in_hours = local.fixed_values.str_backup_interval_hours
│ 
╵

Expected Behaviour

provider should not enforce a value of "12" or "24" for HyperScale SKUs.

Rationale

If I set an allowed value, e.g.

short_term_retention_policy {
    retention_days           = 7
    backup_interval_in_hours = 24
  }

then the change gets applied - But the next run of "terrraform plan" will then show the following configuration drift:

      ~ short_term_retention_policy {
          ~ backup_interval_in_hours = 0 -> 24
            # (1 unchanged attribute hidden)
        }

Conclusion: the API sets the value internally to 0 for Hyperscale DBs.

This behavior has changed recently as it seems (within last few days?)

Actual Behaviour

No response

Steps to Reproduce

No response

Important Factoids

No response

References

No response

@github-actions github-actions bot added service/mssql Microsoft SQL Server v/4.x labels Oct 21, 2024
@fotto
Copy link
Author

fotto commented Oct 21, 2024

Workaround: for HyperScale DB set a value that gets accepted by provider plus a suitable ignore_changes setting, e.g.

resource "azurerm_mssql_database" "this" {
  name      = var.name
  server_id = var.server_id

  sku_name = "HS_S_Gen5_2"

  ...

  short_term_retention_policy {
    retention_days           = 7
    backup_interval_in_hours = 24  # only dummy. will internally be set to 0
  }

  ...

  lifecycle {
    ignore_changes = [ short_term_retention_policy[0].backup_interval_in_hours ]
  }

@sinbai
Copy link
Contributor

sinbai commented Oct 22, 2024

Hi @fotto thanks for opening this issue. I assume that after PR is merged, for HyperScale DB , by not specifying a value of backup_interval_in_hours instead set it to 0. Could you please remove it and try again? Like this:

resource "azurerm_mssql_database" "this" {
  name      = var.name
  server_id = var.server_id

  sku_name = "HS_S_Gen5_2"

  ...

  short_term_retention_policy {
    retention_days           = 7
  }

@fotto
Copy link
Author

fotto commented Oct 22, 2024

Hi @sinbai , many thanks for that hint. I can confirm that it solves the issue:

  • tested for update
  • and for creation of new HyperScale DB

So, the issue boils down to a pending documentation update for azurerm_mssql_database.
I suggest to add something like this to the description of backup_interval_in_hours:

This attribute must not be set for Hyperscale DBs or for DBs running within a Hyperscale Elastic Pool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants