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.6k stars 4.65k forks source link

compute.VirtualMachineScaleSetsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="Parameter 'dataDisk.name' is not allowed." Target="dataDisk.name" #23275

Open neeravjvyas opened 1 year ago

neeravjvyas commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

1.3.1

AzureRM Provider Version

3.25

Affected Resource(s)/Data Source(s)

azurerm_azurerm_linux_virtual_machine_scale_set

Terraform Configuration Files

resource "azurerm_linux_virtual_machine_scale_set" "vmss" {
  name                            = var.vmss_name
  resource_group_name             = var.resource_group_name
  location                        = var.location
  sku                             = var.size
  instances                       = var.vmss_instances
  disable_password_authentication = true
  computer_name_prefix            = var.vmss_name
  upgrade_mode                    = var.upgrade_mode
  source_image_id                 = var.source_image_id
  admin_username                  = var.admin_username
  tags                            = merge(local.resource_tags, local.tags, var.tags, tomap({ "CreatedOn" = local.date }))

  admin_ssh_key {
    username   = var.admin_username
    public_key = var.admin_ssh_public_key
  }

  lifecycle {
    ignore_changes = [tags["CreatedOn"]]
  }

  dynamic "identity" {
    for_each = var.use_managed_identity ? [1] : []
    content {
      type         = var.identity_type
      identity_ids = var.identity_ids
    }
  }

  os_disk {
    caching                   = var.caching
    storage_account_type      = var.storage_account_type
    disk_size_gb              = var.disk_size_gb
    write_accelerator_enabled = var.write_accelerator_enabled
    disk_encryption_set_id    = var.disk_encryption_set_id
  }

  data_disk {
    name                      = var.data_disk_name
    caching                   = var.data_disk_caching
    create_option             = var.create_option
    disk_size_gb              = var.data_disk_disk_size_gb
    lun                       = var.data_disk_lun
    storage_account_type      = var.data_disk_storage_account_type
    disk_encryption_set_id    = var.disk_encryption_set_id
    write_accelerator_enabled = var.data_disk_write_accelerator_enabled
  }

  boot_diagnostics {
    storage_account_uri = var.storage_account_uri
  }

  network_interface {
    name                          = "${var.vmss_name}-${var.network_interface_name}"
    primary                       = true
    enable_ip_forwarding          = false
    dns_servers                   = var.dns_servers
    enable_accelerated_networking = var.enable_accelerated_networking
    network_security_group_id     = var.nsg_id

    ip_configuration {
      primary                                = true
      name                                   = "${var.vmss_name}-ipconfig"
      subnet_id                              = var.subnet_id
      load_balancer_backend_address_pool_ids = var.lb_backend_ids
      application_security_group_ids         = var.app_security_group_ids
    }
  }
  zone_balance = var.zone_balance #true
  zones        = var.zones
}

Debug Output/Panic Output

rror: creating Linux Virtual Machine Scale Set: (Name "xyz" / Resource Group "xyz"): compute.VirtualMachineScaleSetsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="Parameter 'dataDisk.name' is not allowed." Target="dataDisk.name"
│ 
│   with module.vmss.azurerm_linux_virtual_machine_scale_set.vmss,
│   on .terraform/modules/vmss/main.tf line 13, in resource "azurerm_linux_virtual_machine_scale_set" "vmss":
│   13: resource "azurerm_linux_virtual_machine_scale_set" "vmss" {
│ 
╵
##[error]Bash exited with code '1'.
##[error]Bash wrote one or more lines to the standard error stream.
##[error]╷
│ Error: creating Linux Virtual Machine Scale Set: (Name "xyz" / Resource Group "xyz"): compute.VirtualMachineScaleSetsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="Parameter 'dataDisk.name' is not allowed." Target="dataDisk.name"
│ 
│   with module.vmss.azurerm_linux_virtual_machine_scale_set.vmss,
│   on .terraform/modules/vmss/main.tf line 13, in resource "azurerm_linux_virtual_machine_scale_set" "vmss":
│   13: resource "azurerm_linux_virtual_machine_scale_set" "vmss" {

Expected Behaviour

VMSS should be deployed along with datadisk names as we supplied

Actual Behaviour

When supplying datadisk name in data_disk block, it fails with above error. However, when done without name, it works data_disk { name = var.data_disk_name caching = var.data_disk_caching create_option = var.create_option disk_size_gb = var.data_disk_disk_size_gb lun = var.data_disk_lun storage_account_type = var.data_disk_storage_account_type disk_encryption_set_id = var.disk_encryption_set_id write_accelerator_enabled = var.data_disk_write_accelerator_enabled }

boot_diagnostics { storage_account_uri = var.storage_account_uri }

Steps to Reproduce

No response

Important Factoids

No response

References

No response

rcskosir commented 2 months ago

Thanks for opening this issue. Have you been able to try this on any of the more recent 3.x versions or on the new 4.x versions to see if this issue still persists?