hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.56k stars 4.62k forks source link

azurerm_mssql_virtual_machine storage_configuration DefaultFilePath error #22877

Open jwshive opened 1 year ago

jwshive commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

v1.5.4

AzureRM Provider Version

v3.68.0

Affected Resource(s)/Data Source(s)

azurerm_mssql_virtual_machine

Terraform Configuration Files

resource "azurerm_mssql_virtual_machine" "sql-server-vm-config" {
  count                 = var.sql-vm-count
  virtual_machine_id    = azurerm_windows_virtual_machine.sql-servers-vm[count.index].id
  sql_license_type      = var.sql-license-type
  sql_connectivity_port = var.sql-connectivity-port
  sql_connectivity_type = var.sql-connectivity-type
  tags                  = merge(local.common-tags)

    storage_configuration {
      disk_type             = "EXTEND"
      storage_workload_type = "OLTP"
      system_db_on_data_disk_enabled = true
      temp_db_settings {
        default_file_path = var.sql-temp-default-file-path
        luns              = []
        data_file_count = var.data-file-count
        data_file_size_mb = var.data-file-size-mb
        data_file_growth_in_mb = var.data-file-growth-mb
        log_file_size_mb = var.log-file-size-mb
        log_file_growth_mb = var.log-file-growth-mb
      }
    }

  sql_instance {
    adhoc_workloads_optimization_enabled = var.sql-instance-settings.adhoc_workloads_optimization_enabled
    instant_file_initialization_enabled  = var.sql-instance-settings.instant_file_initialization_enabled
    max_dop                              = var.sql-instance-settings.max_dop
    max_server_memory_mb                 = var.sql-instance-settings.max_server_memory_mb
    collation                            = var.sql-instance-settings.collation
    lock_pages_in_memory_enabled         = var.sql-instance-settings.lock_pages_in_memory_enabled
  }

  r_services_enabled = var.r-services-enabled

  lifecycle {
    ignore_changes = [sql_instance, sql_connectivity_port, sql_connectivity_type]
  }

}

Debug Output/Panic Output

# azurerm_mssql_virtual_machine.sql-server-vm-config[0] will be updated in-place
  ~ resource "azurerm_mssql_virtual_machine" "sql-server-vm-config" {
        id                    = "/subscriptions/00000000-0000-0000-0000-0000000000/resourceGroups/myrg-dev-v1-rg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/mysqlvm-0"
        tags                  = {
            "application" = "hidden"
            "department"  = "IT"
            "environment" = "dev"
            "owner"       = "hidden"
        }
        # (4 unchanged attributes hidden)

      + storage_configuration {
          + disk_type                      = "EXTEND"
          + storage_workload_type          = "OLTP"
          + system_db_on_data_disk_enabled = true

          + temp_db_settings {
              + data_file_count        = 4
              + data_file_growth_in_mb = 1024
              + data_file_size_mb      = 1024
              + default_file_path      = "D:\\TempDB"
              + log_file_growth_mb     = 1024
              + log_file_size_mb       = 1024
              + luns                   = []
            }
        }
    }

╷
│ Error: creating Sql Virtual Machine (Subscription: "8972ecc9-176b-4432-bc62-9abe367318b2"
│ Resource Group Name: "customtracker-dev-v1-rg"
│ Sql Virtual Machine Name: "cstmtrkrsql-0"): performing CreateOrUpdate: sqlvirtualmachines.SqlVirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="InvalidArgument" Message="Invalid argument 'DefaultFilePath'."
│
│   with azurerm_mssql_virtual_machine.sql-server-vm-config[0],
│   on sql-virtual-machine.tf line 45, in resource "azurerm_mssql_virtual_machine" "sql-server-vm-config":
│   45: resource "azurerm_mssql_virtual_machine" "sql-server-vm-config" {
│
╵

Expected Behaviour

I expect a successful apply command with the temp_db_settings changed on the SQL VM.

Actual Behaviour

Documented Above

Steps to Reproduce

No response

Important Factoids

No response

References

No response

wuxu92 commented 1 year ago

hi @jwshive is this a dup with https://github.com/hashicorp/terraform-provider-azurerm/issues/19925?

jwshive commented 1 year ago

I can't say. They are for the same resource but not the same block nor error message. The similarity is both blocks is using extend but I personally couldn't say that makes the root cause the same.

jwshive commented 1 year ago

Seems to be related to the extend operation. If I use new, I don't have any issues.

GAW99 commented 11 months ago

We have the same issue. When we try to update Tags (nothing related to SQL or disk configuration) on SQL server we receive such error.