پرش به مطلب اصلی

arvancloud_iaas_snapshot_volume (Resource)

Creates a new volume from an existing snapshot. This resource allows you to restore data from snapshots or clone volumes by creating a new volume from a snapshot. All attributes except computed fields require resource replacement if changed.

Example Usage

# Example 1: Restore volume from a backup snapshot
resource "arvancloud_iaas_snapshot_volume" "restored_volume" {
snapshot_id = "snap-abc123"
name = "restored-production-data"
description = "Production data restored from backup"
}

# Example 2: Clone a volume via snapshot
data "arvancloud_iaas_snapshots" "latest_backup" {
region = "ir-thr-ba1"
}

resource "arvancloud_iaas_snapshot_volume" "cloned_volume" {
snapshot_id = data.arvancloud_iaas_snapshots.latest_backup.snapshots[0].id
name = "dev-environment-clone"
description = "Clone of production data for development"
}

# Example 3: Create multiple volumes from the same snapshot
resource "arvancloud_iaas_snapshot_volume" "replica" {
count = 3

snapshot_id = var.snapshot_id
name = "replica-${count.index + 1}"
description = "Replica ${count.index + 1} created from snapshot"
}

# Outputs
output "volume_id" {
description = "ID of the created volume"
value = arvancloud_iaas_snapshot_volume.restored_volume.id
}

output "volume_size" {
description = "Size of the created volume in GB"
value = arvancloud_iaas_snapshot_volume.restored_volume.size
}

output "volume_region" {
description = "Region where the volume is located"
value = arvancloud_iaas_snapshot_volume.restored_volume.region
}

output "availability_zone" {
description = "Availability zone of the volume"
value = arvancloud_iaas_snapshot_volume.restored_volume.availability_zone
}

output "snapshot_name" {
description = "Name of the source snapshot"
value = arvancloud_iaas_snapshot_volume.restored_volume.snapshot_name
}

Schema

Required

  • name (String) The name of the volume to create. Changing this forces a new resource to be created.
  • snapshot_id (String) The ID of the snapshot to create the volume from. Changing this forces a new resource to be created.

Optional

  • description (String) An optional description for the volume. Changing this forces a new resource to be created.

Read-Only

  • availability_zone (String) The availability zone where the volume is located.
  • created_at (String) The timestamp when the volume was created.
  • id (String) The unique identifier of the created volume.
  • region (String) The region where the volume is located.
  • size (Number) The size of the created volume in GB.
  • snapshot_name (String) The name of the source snapshot.
  • status (String) The current status of the volume (e.g., available, in-use, creating).
  • type (String) The type of the volume (e.g., ssd, hdd).

Import

Import is supported using the following syntax:

terraform import arvancloud_iaas_snapshot_volume.example "ir-thr-si1:e76c3f7a-527d-4f37-ae6a-9a2b6c37f9f0"