terraform-provider-azapi icon indicating copy to clipboard operation
terraform-provider-azapi copied to clipboard

Microsoft.Compute/virtualMachines@2022-11-01 disks keep re-attaching

Open mpjtaylor opened this issue 1 year ago • 3 comments

Terraform 1.4.4 azapi 1.6.0

resource "azapi_resource" "virtualmachine_rehosted" {
  count     = local.create_rehosted_virtual_machine ? 1 : 0
  type      = "Microsoft.Compute/virtualMachines@2022-11-01"
  name      = local.virtual_machine_name
  location  = var.location
  parent_id = data.azurerm_resource_group.virtualmachine.id
  body = jsonencode({
    identity = {
      type = "SystemAssigned"
    }
    properties = {
      hardwareProfile = {
        vmSize = var.vm_size
      }
      networkProfile = {
        networkInterfaces = [{
          id = azurerm_network_interface.virtualmachine[0].id
        }]
      }
      storageProfile = {
        osDisk = {
          createOption = "Attach"
          managedDisk = {
            storageAccountType = var.disk_profiles.rehosted_machine.operating_system.disk_storage_account_type != null ? var.disk_profiles.rehosted_machine.operating_system.disk_storage_account_type : "StandardSSD_LRS"
            id                 = azurerm_managed_disk.os_disk[0].id
          }
          osType = var.disk_profiles.disk_operating_system
          name   = azurerm_managed_disk.os_disk[0].name
        }
        dataDisks = local.hosted_data_disks
      }
      capacityReservation = {
        capacityReservationGroup = {
          id = local.create_capacity ? data.azapi_resource.support_capacity_group[0].id : null
        }
      }
      diagnosticsProfile = {
        bootDiagnostics = {
          enabled    = var.enable_boot_diagnostics
          storageUri = var.enable_boot_diagnostics ? format("https://%s.blob.core.windows.net", data.azurerm_storage_account.staging[0].name) : null
        }
      }
      licenseType = local.virtual_machine_license
    }
    zones = [tostring(var.disk_profiles.disk_availability_zones.disk_primary_zone)]
  })
  schema_validation_enabled = false
  tags                      = merge(local.tags, local.vmtags, local.provisioningtags)
}

No visible changes to whats being removed to whats being added.

mpjtaylor avatar Jun 15 '23 11:06 mpjtaylor

Hi @mpjtaylor ,

Thank you for taking time to report this issue!

I'm not sure what the issue looks like? Is it saying the whole body is sensitive, so you couldn't see the detailed changes?

ms-henglu avatar Jun 16 '23 02:06 ms-henglu

1 2

Disks removed and readded

mpjtaylor avatar Jun 16 '23 06:06 mpjtaylor

Sorry for late response. It seems the lun fields are changed?

ms-henglu avatar Mar 13 '24 05:03 ms-henglu