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_elasticpool license_type can't be set to null when changing from vCore to DTU model #22311

Closed
1 task done
reschex opened this issue Jun 28, 2023 · 2 comments · Fixed by #23262
Closed
1 task done
Labels
service/mssql Microsoft SQL Server v/3.x

Comments

@reschex
Copy link

reschex commented Jun 28, 2023

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

Terraform Version

1.5.0

AzureRM Provider Version

3.62.1

Affected Resource(s)/Data Source(s)

azurerm_mssql_elasticpool

Terraform Configuration Files

variable "db_performance_tier" {
  type        = string
  default     = ""
}

resource "azurerm_resource_group" "this" {
  name     = "resourcepool_test"
  location = "West Europe"

}

resource "azurerm_mssql_server" "this" {
  name                         = azurerm_resource_group.this.name
  resource_group_name          = azurerm_resource_group.this.name
  location                     = azurerm_resource_group.this.location
  version                      = "12.0"
  administrator_login          = "sql_admin"
  administrator_login_password = "YOUR PASSWORD HERE"
  minimum_tls_version          = "1.2"
}

locals {
  db_performance_tiers = {
    default = {
      tier     = "Standard"
      name     = "StandardPool"
      license_type = null
      capacity = 50
      min_capacity = 10
    }
    high = {
      tier     = "GeneralPurpose"
      name     = "GP_Gen5"
      family   = "Gen5"
      license_type = "LicenseIncluded"
      capacity = 6
      min_capacity = 0.25
    }
  }

  db_performance_tier = merge(local.db_performance_tiers.default, lookup(local.db_performance_tiers, var.db_performance_tier, local.db_performance_tiers.default))

}

resource "azurerm_mssql_elasticpool" "this" {
  name                = azurerm_resource_group.this.name
  resource_group_name = azurerm_resource_group.this.name
  location            = azurerm_resource_group.this.location
  server_name         = azurerm_mssql_server.this.name
  license_type        = local.db_performance_tier.license_type
  max_size_gb         = 5

  sku {
    name     = local.db_performance_tier.name
    tier     = local.db_performance_tier.tier
    family   = contains(keys(local.db_performance_tier), "family") ? local.db_performance_tier.family : null
    capacity = local.db_performance_tier.capacity
  }

  per_database_settings {
    min_capacity = local.db_performance_tier.min_capacity
    max_capacity = local.db_performance_tier.capacity
  }
}

Debug Output/Panic Output

Error: `license_type` can only be configured when `sku.0.tier` is set to `GeneralPurpose` or `BusinessCritical`

Expected Behaviour

when changing the var db_performance_tier from "high" to "", the pool should get downgraded from vCore model to eDTU model.

Actual Behaviour

terraform apply fails with this error:

Error: `license_type` can only be configured when `sku.0.tier` is set to `GeneralPurpose` or `BusinessCritical`

the plan doesn't show the license_type parameter being changed back to null:

Terraform will perform the following actions:

  # module.sql_server.azurerm_mssql_elasticpool.this will be updated in-place
  ~ resource "azurerm_mssql_elasticpool" "this" {
        id                             = "XXXX"
        name                           = "XXXX"
        tags                           = {}
        # (8 unchanged attributes hidden)

      ~ per_database_settings {
          ~ max_capacity = 6 -> 50
          ~ min_capacity = 0.25 -> 10
        }

      ~ sku {
          ~ capacity = 6 -> 50
          - family   = "Gen5" -> null
          ~ name     = "GP_Gen5" -> "StandardPool"
          ~ tier     = "GeneralPurpose" -> "Standard"
        }
    }

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

Steps to Reproduce

terraform apply with the var.db_performance_tier set to ""
terraform apply with the var.db_performance_tier set to "high"
terraform apply with the var.db_performance_tier set back to ""

Important Factoids

No response

References

No response

@rcskosir
Copy link
Contributor

@reschex Thank you for taking the time to open this issue. Please subscribe to PR #23262 that @sinbai has opened related to this issue.

Copy link

github-actions bot commented May 6, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/mssql Microsoft SQL Server v/3.x
Projects
None yet
3 participants