Hi folks, I’m struggling when trying to set a variable that TF will understand it’s an optional variable for a specific module.
I’m trying to set the variable license_type
for mssql database as follows:
variable "database_license_type" {
type = string
default = "LicenseIncluded"
}
and then I tried to define the license_type
under resource
in both ways, but didn’t work:
resource "azurerm_mssql_database" "sql-database" {
license_type = "${ var.serverless == "true" ? null : "LicenseIncluded"}"'
*or*
license_type = coalesce(each.value.serverless, true) ? try(each.value.license_type, var.database_license_type) : null
}
also tried to declare license_type under locals:
locals {
license_type = "${ var.serverless == "true" ? null : "LicenseIncluded"}"
}
-Also tried to define the var as null, but didn’t help!-
The error I get after running the plan is:
│ Error: serverless databases do not support license type
│
│ with module.sup-fp-we-sql-server.azurerm_mssql_database.sql-database["sup-profi-processengine"],
│ on ../modules/tf-azurerm-sql/database.tf line 1, in resource "azurerm_mssql_database" "sql-database":
│ 1: resource "azurerm_mssql_database" "sql-database" {
│
╵
╷
│ Error: serverless databases do not support license type
│
│ with module.sup-fp-we-sql-server.azurerm_mssql_database.sql-database["sup-job-database"],
│ on ../modules/tf-azurerm-sql/database.tf line 1, in resource "azurerm_mssql_database" "sql-database":
│ 1: resource "azurerm_mssql_database" "sql-database" {
it seems to be already an optional value in Terraform azurerm registry:
-
license_type
- (Optional) Specifies the license type applied to this database. Possible values areLicenseIncluded
andBasePrice
.
I think I only saw this error after upgrading the azurerum module to v3.0.2
To me, it seems that Terraform cannot omit the variable and treat it as an optional one, any ideas?
I appreciate your great support !
Best, Kareem