Azure / terraform-provider-azapi

Terraform provider for Azure Resource Manager Rest API
https://registry.terraform.io/providers/Azure/azapi/latest
Mozilla Public License 2.0
193 stars 49 forks source link

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

Closed mpjtaylor closed 3 weeks ago

mpjtaylor commented 1 year ago

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.

ms-henglu commented 1 year ago

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?

mpjtaylor commented 1 year ago

1 2

Disks removed and readded

ms-henglu commented 8 months ago

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

ms-henglu commented 3 weeks ago

I'll close this issue as there's no response, but feel free to reopen it if there's any questions.