arvancloud_iaas_volume_attachment (Resource)
Manages the attachment of a block storage volume to a compute server instance. This resource attaches an existing volume to a server, making the volume accessible from the server. The volume must already exist and must not be attached to another server.
Example Usage
# Create a volume
resource "arvancloud_iaas_volume" "data" {
name = "data-volume"
description = "Data storage for web application"
size = 50
type = "ssd"
availability_zone = "ir-central1-a"
}
# Create a server
resource "arvancloud_iaas_server" "web" {
name = "web-server"
flavor = "g1-2-2"
image = "ubuntu-22.04"
availability_zone = "ir-central1-a"
}
# Attach the volume to the server
resource "arvancloud_iaas_volume_attachment" "web_data" {
volume_id = arvancloud_iaas_volume.data.id
server_id = arvancloud_iaas_server.web.id
availability_zone = "ir-central1-a"
}
# Outputs
output "attachment_id" {
description = "Composite ID of the volume attachment"
value = arvancloud_iaas_volume_attachment.web_data.id
}
output "device_path" {
description = "Device path where volume is attached (e.g., /dev/vdb)"
value = arvancloud_iaas_volume_attachment.web_data.device
}
output "attached_at" {
description = "Timestamp when the volume was attached"
value = arvancloud_iaas_volume_attachment.web_data.attached_at
}
output "volume_status" {
description = "Current status of the volume after attachment"
value = arvancloud_iaas_volume_attachment.web_data.status
}
Schema
Required
availability_zone(String) Availability zone where the volume and server reside (e.g.,ir-central1-a).server_id(String) ID of the compute server instance to attach the volume to.volume_id(String) ID of the volume to attach.
Read-Only
attached_at(String) Timestamp when the volume was attached to the server.device(String) Device path where the volume is attached on the server (e.g.,/dev/vdb).id(String) Unique identifier for this attachment (format:{volume_id}:{server_id}).status(String) Status of the volume after attachment (e.g.,in-use).
Import
Import is supported using the following syntax:
terraform import arvancloud_iaas_volume_attachment.example "ir-thr-si1:e76c3f7a-527d-4f37-ae6a-9a2b6c37f9f0:ab5f9ae1-5c5e-44e2-8923-b11ea5a6e9c2"