2017-01-19 15:08:56 +01:00
|
|
|
---
|
|
|
|
layout: "alicloud"
|
|
|
|
page_title: "Alicloud: alicloud_disk_attachment"
|
|
|
|
sidebar_current: "docs-alicloud-resource-disk-attachment"
|
|
|
|
description: |-
|
|
|
|
Provides a ECS Disk Attachment resource.
|
|
|
|
---
|
|
|
|
|
|
|
|
# alicloud\_disk\_attachment
|
|
|
|
|
|
|
|
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" {
|
2017-02-18 23:48:50 +01:00
|
|
|
name = "terraform-test-group"
|
|
|
|
description = "New security group"
|
2017-01-19 15:08:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "alicloud_disk" "ecs_disk" {
|
2017-02-18 23:48:50 +01:00
|
|
|
availability_zone = "cn-beijing-a"
|
|
|
|
size = "50"
|
2017-01-19 15:08:56 +01:00
|
|
|
|
2017-02-18 23:48:50 +01:00
|
|
|
tags {
|
|
|
|
Name = "TerraformTest-disk"
|
|
|
|
}
|
2017-01-19 15:08:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "alicloud_instance" "ecs_instance" {
|
2017-02-18 23:48:50 +01:00
|
|
|
image_id = "ubuntu_140405_64_40G_cloudinit_20161115.vhd"
|
|
|
|
instance_type = "ecs.s1.small"
|
|
|
|
availability_zone = "cn-beijing-a"
|
|
|
|
security_groups = ["${alicloud_security_group.ecs_sg.id}"]
|
|
|
|
instance_name = "Hello"
|
|
|
|
instance_network_type = "classic"
|
|
|
|
internet_charge_type = "PayByBandwidth"
|
|
|
|
|
|
|
|
tags {
|
|
|
|
Name = "TerraformTest-instance"
|
|
|
|
}
|
2017-01-19 15:08:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "alicloud_disk_attachment" "ecs_disk_att" {
|
2017-02-18 23:48:50 +01:00
|
|
|
disk_id = "${alicloud_disk.ecs_disk.id}"
|
|
|
|
instance_id = "${alicloud_instance.ecs_instance.id}"
|
|
|
|
device_name = "/dev/xvdb"
|
2017-01-19 15:08:56 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
|
|
|
* `instance_id` - (Required, Forces new resource) ID of the Instance to attach to.
|
|
|
|
* `disk_id` - (Required, Forces new resource) ID of the Disk to be attached.
|
|
|
|
* `device_name` - (Required, Forces new resource) The device name to expose to the instance (for example, /dev/xvdb).
|
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
|
|
|
|
|
|
|
* `instance_id` - ID of the Instance.
|
|
|
|
* `disk_id` - ID of the Disk.
|
|
|
|
* `device_name` - The device name exposed to the instance.
|