# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import warnings
import pulumi
import pulumi.runtime
from typing import Any, Dict, List, Mapping, Optional, Tuple, Union
from .. import _utilities, _tables

__all__ = ['DiskAttachment']


class DiskAttachment(pulumi.CustomResource):
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 device_name: Optional[pulumi.Input[str]] = None,
                 disk_id: Optional[pulumi.Input[str]] = None,
                 instance_id: Optional[pulumi.Input[str]] = None,
                 __props__=None,
                 __name__=None,
                 __opts__=None):
        """
        Provides an Alicloud ECS Disk Attachment as a resource, to attach and detach disks from ECS Instances.

        ## Example Usage

        Basic usage

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        # Create a new ECS disk-attachment and use it attach one disk to a new instance.
        ecs_sg = alicloud.ecs.SecurityGroup("ecsSg", description="New security group")
        ecs_disk = alicloud.ecs.Disk("ecsDisk",
            availability_zone="cn-beijing-a",
            size=50,
            tags={
                "Name": "TerraformTest-disk",
            })
        ecs_instance = alicloud.ecs.Instance("ecsInstance",
            image_id="ubuntu_18_04_64_20G_alibase_20190624.vhd",
            instance_type="ecs.n4.small",
            availability_zone="cn-beijing-a",
            security_groups=[ecs_sg.id],
            instance_name="Hello",
            internet_charge_type="PayByBandwidth",
            tags={
                "Name": "TerraformTest-instance",
            })
        ecs_disk_att = alicloud.ecs.DiskAttachment("ecsDiskAtt",
            disk_id=ecs_disk.id,
            instance_id=ecs_instance.id)
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] device_name: The device name has been deprecated, and when attaching disk, it will be allocated automatically by system according to default order from /dev/xvdb to /dev/xvdz.
        :param pulumi.Input[str] disk_id: ID of the Disk to be attached.
        :param pulumi.Input[str] instance_id: ID of the Instance to attach to.
        """
        if __name__ is not None:
            warnings.warn("explicit use of __name__ is deprecated", DeprecationWarning)
            resource_name = __name__
        if __opts__ is not None:
            warnings.warn("explicit use of __opts__ is deprecated, use 'opts' instead", DeprecationWarning)
            opts = __opts__
        if opts is None:
            opts = pulumi.ResourceOptions()
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.version is None:
            opts.version = _utilities.get_version()
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = dict()

            if device_name is not None:
                warnings.warn("Attribute device_name is deprecated on disk attachment resource. Suggest to remove it from your template.", DeprecationWarning)
                pulumi.log.warn("device_name is deprecated: Attribute device_name is deprecated on disk attachment resource. Suggest to remove it from your template.")
            __props__['device_name'] = device_name
            if disk_id is None:
                raise TypeError("Missing required property 'disk_id'")
            __props__['disk_id'] = disk_id
            if instance_id is None:
                raise TypeError("Missing required property 'instance_id'")
            __props__['instance_id'] = instance_id
        super(DiskAttachment, __self__).__init__(
            'alicloud:ecs/diskAttachment:DiskAttachment',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            device_name: Optional[pulumi.Input[str]] = None,
            disk_id: Optional[pulumi.Input[str]] = None,
            instance_id: Optional[pulumi.Input[str]] = None) -> 'DiskAttachment':
        """
        Get an existing DiskAttachment resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.

        :param str resource_name: The unique name of the resulting resource.
        :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] device_name: The device name has been deprecated, and when attaching disk, it will be allocated automatically by system according to default order from /dev/xvdb to /dev/xvdz.
        :param pulumi.Input[str] disk_id: ID of the Disk to be attached.
        :param pulumi.Input[str] instance_id: ID of the Instance to attach to.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["device_name"] = device_name
        __props__["disk_id"] = disk_id
        __props__["instance_id"] = instance_id
        return DiskAttachment(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="deviceName")
    def device_name(self) -> pulumi.Output[str]:
        """
        The device name has been deprecated, and when attaching disk, it will be allocated automatically by system according to default order from /dev/xvdb to /dev/xvdz.
        """
        return pulumi.get(self, "device_name")

    @property
    @pulumi.getter(name="diskId")
    def disk_id(self) -> pulumi.Output[str]:
        """
        ID of the Disk to be attached.
        """
        return pulumi.get(self, "disk_id")

    @property
    @pulumi.getter(name="instanceId")
    def instance_id(self) -> pulumi.Output[str]:
        """
        ID of the Instance to attach to.
        """
        return pulumi.get(self, "instance_id")

    def translate_output_property(self, prop):
        return _tables.CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop

    def translate_input_property(self, prop):
        return _tables.SNAKE_TO_CAMEL_CASE_TABLE.get(prop) or prop

