pulumi_wasm_providers_azure_mini::compute

Module data_disk_attachment

source
Expand description

Manages attaching a Disk to a Virtual Machine.

NOTE: Data Disks can be attached either directly on the azure.compute.VirtualMachine resource, or using the azure.compute.DataDiskAttachment resource - but the two cannot be used together. If both are used against the same Virtual Machine, spurious changes will occur.

Please Note: only Managed Disks are supported via this separate resource, Unmanaged Disks can be attached using the storage_data_disk block in the azure.compute.VirtualMachine resource.

§Example Usage

configuration:
  prefix:
    type: string
    default: example
resources:
  example:
    type: azure:core:ResourceGroup
    properties:
      name: ${prefix}-resources
      location: West Europe
  main:
    type: azure:network:VirtualNetwork
    properties:
      name: ${prefix}-network
      addressSpaces:
        - 10.0.0.0/16
      location: ${example.location}
      resourceGroupName: ${example.name}
  internal:
    type: azure:network:Subnet
    properties:
      name: internal
      resourceGroupName: ${example.name}
      virtualNetworkName: ${main.name}
      addressPrefixes:
        - 10.0.2.0/24
  mainNetworkInterface:
    type: azure:network:NetworkInterface
    name: main
    properties:
      name: ${prefix}-nic
      location: ${example.location}
      resourceGroupName: ${example.name}
      ipConfigurations:
        - name: internal
          subnetId: ${internal.id}
          privateIpAddressAllocation: Dynamic
  exampleVirtualMachine:
    type: azure:compute:VirtualMachine
    name: example
    properties:
      name: ${vmName}
      location: ${example.location}
      resourceGroupName: ${example.name}
      networkInterfaceIds:
        - ${mainNetworkInterface.id}
      vmSize: Standard_F2
      storageImageReference:
        publisher: Canonical
        offer: 0001-com-ubuntu-server-jammy
        sku: 22_04-lts
        version: latest
      storageOsDisk:
        name: myosdisk1
        caching: ReadWrite
        createOption: FromImage
        managedDiskType: Standard_LRS
      osProfile:
        computerName: ${vmName}
        adminUsername: testadmin
        adminPassword: Password1234!
      osProfileLinuxConfig:
        disablePasswordAuthentication: false
  exampleManagedDisk:
    type: azure:compute:ManagedDisk
    name: example
    properties:
      name: ${vmName}-disk1
      location: ${example.location}
      resourceGroupName: ${example.name}
      storageAccountType: Standard_LRS
      createOption: Empty
      diskSizeGb: 10
  exampleDataDiskAttachment:
    type: azure:compute:DataDiskAttachment
    name: example
    properties:
      managedDiskId: ${exampleManagedDisk.id}
      virtualMachineId: ${exampleVirtualMachine.id}
      lun: '10'
      caching: ReadWrite
variables:
  vmName: ${prefix}-vm

§Import

Virtual Machines Data Disk Attachments can be imported using the resource id, e.g.

$ pulumi import azure:compute/dataDiskAttachment:DataDiskAttachment example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/machine1/dataDisks/disk1

Structs§

Functions§

  • Registers a new resource with the given unique name and arguments