"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataDiskAttachment = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
 * 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 `storageDataDisk` block in the `azure.compute.VirtualMachine` resource.
 *
 * ## Example Usage
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 *
 * const config = new pulumi.Config();
 * const prefix = config.get("prefix") || "example";
 * const vmName = `${prefix}-vm`;
 * const example = new azure.core.ResourceGroup("example", {
 *     name: `${prefix}-resources`,
 *     location: "West Europe",
 * });
 * const main = new azure.network.VirtualNetwork("main", {
 *     name: `${prefix}-network`,
 *     addressSpaces: ["10.0.0.0/16"],
 *     location: example.location,
 *     resourceGroupName: example.name,
 * });
 * const internal = new azure.network.Subnet("internal", {
 *     name: "internal",
 *     resourceGroupName: example.name,
 *     virtualNetworkName: main.name,
 *     addressPrefixes: ["10.0.2.0/24"],
 * });
 * const mainNetworkInterface = new azure.network.NetworkInterface("main", {
 *     name: `${prefix}-nic`,
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     ipConfigurations: [{
 *         name: "internal",
 *         subnetId: internal.id,
 *         privateIpAddressAllocation: "Dynamic",
 *     }],
 * });
 * const exampleVirtualMachine = new azure.compute.VirtualMachine("example", {
 *     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,
 *     },
 * });
 * const exampleManagedDisk = new azure.compute.ManagedDisk("example", {
 *     name: `${vmName}-disk1`,
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     storageAccountType: "Standard_LRS",
 *     createOption: "Empty",
 *     diskSizeGb: 10,
 * });
 * const exampleDataDiskAttachment = new azure.compute.DataDiskAttachment("example", {
 *     managedDiskId: exampleManagedDisk.id,
 *     virtualMachineId: exampleVirtualMachine.id,
 *     lun: 10,
 *     caching: "ReadWrite",
 * });
 * ```
 *
 * ## API Providers
 *
 * <!-- This section is generated, changes will be overwritten -->
 * This resource uses the following Azure API Providers:
 *
 * * `Microsoft.Compute` - 2024-03-01, 2023-04-02
 *
 * ## Import
 *
 * Virtual Machines Data Disk Attachments can be imported using the `resource id`, e.g.
 *
 * ```sh
 * $ pulumi import azure:compute/dataDiskAttachment:DataDiskAttachment example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/machine1/dataDisks/disk1
 * ```
 *
 * > **Note:** This is provider-specific ID matching the format: `{virtualMachineID}/dataDisks/{diskName}`
 */
class DataDiskAttachment extends pulumi.CustomResource {
    /**
     * Get an existing DataDiskAttachment resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state Any extra arguments used during the lookup.
     * @param opts Optional settings to control the behavior of the CustomResource.
     */
    static get(name, id, state, opts) {
        return new DataDiskAttachment(name, state, { ...opts, id: id });
    }
    /** @internal */
    static __pulumiType = 'azure:compute/dataDiskAttachment:DataDiskAttachment';
    /**
     * Returns true if the given object is an instance of DataDiskAttachment.  This is designed to work even
     * when multiple copies of the Pulumi SDK have been loaded into the same process.
     */
    static isInstance(obj) {
        if (obj === undefined || obj === null) {
            return false;
        }
        return obj['__pulumiType'] === DataDiskAttachment.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["caching"] = state?.caching;
            resourceInputs["createOption"] = state?.createOption;
            resourceInputs["lun"] = state?.lun;
            resourceInputs["managedDiskId"] = state?.managedDiskId;
            resourceInputs["virtualMachineId"] = state?.virtualMachineId;
            resourceInputs["writeAcceleratorEnabled"] = state?.writeAcceleratorEnabled;
        }
        else {
            const args = argsOrState;
            if (args?.caching === undefined && !opts.urn) {
                throw new Error("Missing required property 'caching'");
            }
            if (args?.lun === undefined && !opts.urn) {
                throw new Error("Missing required property 'lun'");
            }
            if (args?.managedDiskId === undefined && !opts.urn) {
                throw new Error("Missing required property 'managedDiskId'");
            }
            if (args?.virtualMachineId === undefined && !opts.urn) {
                throw new Error("Missing required property 'virtualMachineId'");
            }
            resourceInputs["caching"] = args?.caching;
            resourceInputs["createOption"] = args?.createOption;
            resourceInputs["lun"] = args?.lun;
            resourceInputs["managedDiskId"] = args?.managedDiskId;
            resourceInputs["virtualMachineId"] = args?.virtualMachineId;
            resourceInputs["writeAcceleratorEnabled"] = args?.writeAcceleratorEnabled;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(DataDiskAttachment.__pulumiType, name, resourceInputs, opts);
    }
}
exports.DataDiskAttachment = DataDiskAttachment;
//# sourceMappingURL=dataDiskAttachment.js.map