pulumi / pulumi-azure

A Microsoft Azure Pulumi resource package, providing multi-language access to Azure
Apache License 2.0
134 stars 51 forks source link

Error when creating a VM from an custom image that already has a datadisk and without specifying diskSizeGb #268

Open nithril opened 5 years ago

nithril commented 5 years ago

Pulumi version: v0.17.14

I try to create a VM from an image referenced by storageImageReference. That image is a custom image created from a VM that already had an os and and data disk.

const virtualMachine = new azure.compute.VirtualMachine(vmName, {
            location: context.resourceGroups.pro.location,

            name: vmName,

            "zones": `${zone}`,

            networkInterfaceIds: [networkInterface.id],
            osProfile: {
                "computerName": `${vmsSpec.name}-${vmNum}`,
                "adminUsername": "",
                "adminPassword": "",
            },
            osProfileLinuxConfig: context.config.vmAuth,
            resourceGroupName: context.resourceGroups.pro.name,
            storageImageReference: {
                id: "/subscriptions/......"
            },
            storageOsDisk: {
                createOption: "fromImage",
                managedDiskType: "Premium_LRS",
                name: `disk-${context.config.shortLocation}-z${zone}-pro-${vmsSpec.name}${vmNum}-os0`,
            },
            storageDataDisks:[
                {
                    lun: 0,
                    caching: "ReadOnly",
                    createOption: "fromImage",
                    managedDiskType: "Premium_LRS",
                    name: `disk-${context.config.shortLocation}-z${zone}-pro-${vmsSpec.name}${vmNum}-data0`,
                }

            ]
            ,
            tags: {
                environment: "staging",
            },
            vmSize: vmsSpec.vmSize,
        });

When executing pulumi up and when the changes are applying, pulumi is throwing the following error:

  error: Plan apply failed: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="The value '0' of parameter 'dataDisk.diskSizeGB' is out of range. Value '0' must be between '1' and '32767' inclusive." Target="dataDisk.diskSizeGB"

Setting diskSizeGb to the size of the datadisk workaround the issue.

Thank you for your help!

stack72 commented 5 years ago

FYI, off the back of this issue, we found that the Terraform docs were not quite correct and a PR was opened there as well https://github.com/terraform-providers/terraform-provider-azurerm/pull/3589

mikhailshilkov commented 1 year ago

Just checked and this still reproduces...