alicloud_ecs_disk
Provides an ECS Disk resource.
For information about ECS Disk and how to use it, see What is Disk.
-> NOTE: Available since v1.122.0.
Example Usage
Basic Usage
data "alicloud_zones" "example" {
available_resource_creation = "VSwitch"
}
resource "alicloud_kms_key" "example" {
description = "terraform-example"
pending_window_in_days = "7"
status = "Enabled"
}
resource "alicloud_ecs_disk" "example" {
zone_id = data.alicloud_zones.example.zones.0.id
disk_name = "terraform-example"
description = "terraform-example"
category = "cloud_efficiency"
size = "30"
encrypted = true
kms_key_id = alicloud_kms_key.example.id
tags = {
Name = "terraform-example"
}
}
Deleting alicloud_ecs_disk
or removing it from your configuration
The alicloud_ecs_disk
resource allows you to manage payment_type = "Subscription"
and delete_with_instance = true
disk,
but Terraform cannot destroy it. Deleting the subscription resource or removing it from your configuration will
remove it from your state file and management, but will not destroy it.
If you want to delete it, you can change it to PayAsYouGo
and setting delete_with_instance = true
and detach it from instance.
Argument Reference
The following arguments are supported:
zone_id
- (Optional, ForceNew) ID of the free zone to which the disk belongs. One of thezone_id
andinstance_id
must be set but can not be set at the same time.availability_zone
- (Deprecated since v1.122.0) Fieldavailability_zone
has been deprecated from provider version 1.122.0. New fieldzone_id
instead.category
- (Optional) Category of the disk. Default value:cloud_efficiency
. Valid Values:cloud
,cloud_efficiency
,cloud_ssd
,cloud_essd
,cloud_auto
,cloud_essd_entry
,elastic_ephemeral_disk_standard
,elastic_ephemeral_disk_premium
.delete_auto_snapshot
- (Optional) Indicates whether the automatic snapshot is deleted when the disk is released. Default value:false
.delete_with_instance
- (Optional) Indicates whether the disk is released together with the instance. Default value:false
.description
- (Optional) Description of the disk. This description can have a string of 2 to 256 characters, It cannot begin with http:// or https://. Default value is null.disk_name
- (Optional) Name of the ECS disk. This name can have a string of 2 to 128 characters, must contain only alphanumeric characters or hyphens, such as "-",".","_", and must not begin or end with a hyphen, and must not begin withhttp://
orhttps://
. Default value isnull
.dry_run
- (Optional) Specifies whether to check the validity of the request without actually making the request.request Default value: false. Valid values:true
: The validity of the request is checked, but the request is not made. Check items include the required parameters, request format, service limits, and available ECS resources. If the check fails, the corresponding error message is returned. If the check succeeds, the DryRunOperation error code is returned.false
: The validity of the request is checked. If the check succeeds, a 2xx HTTP status code is returned and the request is made.
enable_auto_snapshot
- (Optional) Indicates whether to enable creating snapshot automatically.encrypted
- (Optional, ForceNew) Specifies whether to encrypt the disk. Default value:false
. Valid values:true
: Enable.false
: Disable.
instance_id
- (Optional, ForceNew) The ID of the instance to which the created subscription disk is automatically attached.- After you specify the instance ID, the specified
resource_group_id
,tags
, andkms_key_id
parameters are ignored. - One of the
zone_id
andinstance_id
must be set but can not be set at the same time.
- After you specify the instance ID, the specified
kms_key_id
- (Optional, ForceNew) The ID of the KMS key corresponding to the data disk, The specified parameterEncrypted
must betrue
when KmsKeyId is not empty.name
- (Optional, Deprecated since v1.122.0) Fieldname
has been deprecated from provider version 1.122.0. New fielddisk_name
instead.payment_type
- (Optional) Payment method for disk. Valid values:PayAsYouGo
,Subscription
. Default toPayAsYouGo
. If you want to change the disk payment type, theinstance_id
is required.performance_level
- (Optional) Specifies the performance level of an ESSD when you create the ESSD. Valid values:PL0
: A single ESSD delivers up to 10,000 random read/write IOPS.PL1
: A single ESSD delivers up to 50,000 random read/write IOPS.PL2
: A single ESSD delivers up to 100,000 random read/write IOPS.PL3
: A single ESSD delivers up to 1,000,000 random read/write IOPS.
tags
- (Optional) A mapping of tags to assign to the resource.resource_group_id
- (Optional) The Id of resource group which the disk belongs. This attribute only supports adding or updating, not destroying.size
- (Optional) The size of the disk. Unit: GiB. This parameter is required. Valid values:- If
category
is set tocloud
. Valid values:5
to2000
. - If
category
is set tocloud_efficiency
. Valid values:20
to32768
. - If
category
is set tocloud_ssd
. Valid values:20
to32768
. - If
category
is set tocloud_auto
. Valid values:1
to65536
. - If
category
is set tocloud_essd_entry
. Valid values:10
to32768
. - If
category
is set toelastic_ephemeral_disk_standard
. Valid values:64
to8192
. - If
category
is set toelastic_ephemeral_disk_premium
. Valid values:64
to8192
. - If
category
is set tocloud_essd
, the valid values are related toperformance_level
. Valid values:- If
performance_level
is set toPL0
. Valid values:1
to65536
. - If
performance_level
is set toPL1
. Valid values:20
to65536
. - If
performance_level
is set toPL2
. Valid values:461
to65536
. - If
performance_level
is set toPL3
. Valid values:1261
to65536
.
- If
- If
snapshot_id
- (Optional, ForceNew) The ID of the snapshot to use to create the disk. NOTE: If the size of the snapshot specified bysnapshot_id
is larger than the value ofsize
, the size of the created disk is equal to the specified snapshot size. If the size of the snapshot specified bysnapshot_id
is smaller than the value ofsize
, the size of the created disk is equal to the value ofsize
.storage_set_id
- (Optional, ForceNew) The ID of the storage set.storage_set_partition_number
- (Optional, ForceNew) The number of partitions in the storage set.type
- (Optional, Available since v1.122.0) The type to expand cloud disks. Valid Values:online
,offline
. Default tooffline
.offline
: After you resize a disk offline, you must restart the instance by using the console or by calling the RebootInstance operation for the resizing operation to take effect. For more information, see Restart the instance and RebootInstance.online
: After you resize a disk online, the resizing operation takes effect immediately and you do not need to restart the instance. You can resize ultra disks, standard SSDs, and ESSDs online.
-> NOTE: Disk category cloud
has been outdated, and it only can be used none I/O Optimized ECS instances. Recommend cloud_efficiency
and cloud_ssd
disk.
Attributes Reference
The following attributes are exported:
id
- The resource ID in terraform of Disk.status
- The disk status.
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 2 mins) Used when create the Disk.update
- (Defaults to 10 mins) Used when update the Disk.delete
- (Defaults to 2 mins) Used when delete the Disk.
Import
ECS Disk can be imported using the id, e.g.
$ terraform import alicloud_ecs_disk.example d-abcd12345