alicloud_disk_attachment

Updated at:
Copy as MD

-> DEPRECATED: This resource has been renamed to alicloud_ecs_disk_attachment from version 1.122.0.

Provides an Alicloud ECS Disk Attachment as a resource, to attach and detach disks from ECS Instances.

Example Usage

Basic usage

# Create a new ECS disk-attachment and use it attach one disk to a new instance.
resource "alicloud_security_group" "ecs_sg" {
  name        = "terraform-demo-group"
  description = "New security group"
}

resource "alicloud_disk" "ecs_disk" {
  availability_zone = "cn-beijing-a"
  size              = "50"

  tags = {
    Name = "TerraformTest-disk"
  }
}

resource "alicloud_instance" "ecs_instance" {
  image_id             = "ubuntu_18_04_64_20G_alibase_20190624.vhd"
  instance_type        = "ecs.n4.small"
  availability_zone    = "cn-beijing-a"
  security_groups      = [alicloud_security_group.ecs_sg.id]
  instance_name        = "Hello"
  internet_charge_type = "PayByBandwidth"

  tags = {
    Name = "TerraformTest-instance"
  }
}

resource "alicloud_disk_attachment" "ecs_disk_att" {
  disk_id     = alicloud_disk.ecs_disk.id
  instance_id = alicloud_instance.ecs_instance.id
}

Need more examples? VIEW MORE EXAMPLES

Argument Reference

The following arguments are supported:

  • instance_id - (Required, ForceNew) ID of the Instance to attach to.
  • disk_id - (Required, ForceNew) ID of the Disk to be attached.
  • bootable - (Optional, ForceNew) Whether the disk is bootable.
  • delete_with_instance - (Optional) Whether to delete the disk with the instance.
  • key_pair_name - (Optional, ForceNew) The name of the key pair.
  • password - (Optional, ForceNew) The password of the instance.

Attributes Reference

The following attributes are exported:

  • id - The Disk Attachment ID and it formats as <disk_id>:<instance_id>.
  • device - The device name allocated to the disk.

Import

The disk attachment can be imported using the id, e.g.

$ terraform import alicloud_disk_attachment.example d-abc12345678:i-abc12355