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 1.122.0) Fieldavailability_zone
has been deprecated from provider version 1.122.0. New fieldzone_id
instead.category
- (Optional) Category of the disk. Valid values arecloud
,cloud_efficiency
,cloud_ssd
,cloud_essd
,cloud_auto
,cloud_essd_entry
. Default iscloud_efficiency
.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, Computed) 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) If true, the disk will be encrypted, conflict withsnapshot_id
.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, Computed, Deprecated from 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: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 in GiBs. When resize the disk, the new size must be greater than the former value, or you would get an errorInvalidDiskSize.TooSmall
.snapshot_id
- (Optional, ForceNew) A snapshot to base the disk off of. If the disk size required by snapshot is greater thansize
, thesize
will be ignored, conflict withencrypted
.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 in 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
- 本页导读 (0)