This message was deleted.
# general
b
This message was deleted.
m
Hey @mammoth-apple-73256 đź‘‹
m
hey man 🙂
m
All of the resources that are listed in this output are “usage based”. For these type of resources we require you to define a usage file. You can read more about it here: https://www.infracost.io/docs/features/usage_based_resources/
m
ah thanks man! i will check it out
m
Ah sorry actually @mammoth-apple-73256 this is incorrect, sorry I glanced over this too quickly
m
🙂
m
some of these are usage based e.g.
azurerm_application_insights.main
but the
azurerm_mssql_database
should be showing a price
m
yeah thats what confuses me
it shouldve shown for atleast 1 resource
m
could you post the raw terraform block for
azurerm_mssql_database.main
(removing any sensitive information).
I’m especially interested in the
sku_name
attribute
m
2 sec
Copy code
resource "azurerm_mssql_server" "main" {
  name                         = "bousql-${var.environment}"
  resource_group_name          = data.azurerm_resource_group.main.name
  location                     = data.azurerm_resource_group.main.location
  version                      = "12.0"
  administrator_login          = "sqladmin"
  administrator_login_password = random_password.db_password.result
  minimum_tls_version          = "1.2"
  public_network_access_enabled     = true
  
  identity {
    type = "SystemAssigned"
  }
  tags = {
    Environment = "${var.environment}"
  }
}
resource "azurerm_mssql_server_extended_auditing_policy" "main" {
  server_id              = azurerm_mssql_server.main.id
  log_monitoring_enabled = true
}
resource "azurerm_mssql_server_extended_auditing_policy" "testsql" {
  server_id         = azurerm_mssql_server.main.id
  storage_endpoint  = azurerm_storage_account.main.primary_blob_endpoint
  # do not pass the storage account key
  depends_on        = [azurerm_role_assignment.audit_contributor]
}
resource "azurerm_role_assignment" "audit_contributor" {
  scope                = azurerm_storage_account.main.id
  role_definition_name = "Storage Blob Data Contributor"
  principal_id         = azurerm_mssql_server.main.identity[0].principal_id
}
resource "azurerm_mssql_database" "main" {
  name      = "bou-Umbraco-${var.environment}"
  server_id = azurerm_mssql_server.main.id
  collation = "SQL_Latin1_General_CP1_CI_AS"
  sku_name = local.env-test == local.env-acc ? "S3" : "S1"
Copy code
locals {
  env-test = var.environment == "test"
  env-acc = var.environment == "acc"
}
and the locals in the vars file
m
hmm this does look like a bug our side, I’m just running a few things to confirm
what region are you running in @mammoth-apple-73256?
so I’ve found the issue @mammoth-apple-73256, the problem is with this line:
Copy code
resource "azurerm_mssql_server" "main" {
  ...
  location                     = data.azurerm_resource_group.main.location 
}
Infracost’s default behaviour is to parse the raw configuration files, and not contact any cloud providers. This has the benefit of being fast and more secure. However, we can’t evaluate
data
blocks. So what’s happening here is that the
azurerm_mssql_database.main
is using
azurerm_mssql_server.main
to determine the region/location and because this is populated from a
data
block it’s returning empty. Meaning the price lookup fails and gives a 0$. A workaround for you is to use the
--terraform-force-cli
flag which forces infracost to use Terraform binary output. This is slower but should give you a better output. Our side we need to put in a fix to return a default location if we can’t evaluate the expressions, and then give users the option to override this. There’s an open issue here for the latter: https://github.com/infracost/infracost/issues/1796
m
thanks man! 🙂 I will try