alicloud_image_import

Updated at:
Copy as MD

Provides a ECS Image Import resource.

For information about ECS Image Import and how to use it, see What is Image Import.

-> NOTE: Available since v1.69.0.

-> NOTE: You must upload the image file to the object storage OSS in advance.

-> NOTE: The region where the image is imported must be the same region as the OSS bucket where the image file is uploaded.

Example Usage

Basic Usage


variable "name" {
  default = "terraform-image-import-example"
}

resource "random_integer" "default" {
  min = 10000
  max = 99999
}

resource "alicloud_oss_bucket" "default" {
  bucket = "${var.name}-${random_integer.default.result}"
}

resource "alicloud_oss_bucket_object" "default" {
  bucket  = alicloud_oss_bucket.default.id
  key     = "fc/hello.zip"
  content = <<EOF
    # -*- coding: utf-8 -*-
    def handler(event, context):
    print "hello world"
    return 'hello world'
    EOF
}

resource "alicloud_image_import" "default" {
  architecture = "x86_64"
  os_type      = "linux"
  platform     = "Ubuntu"
  license_type = "Auto"
  image_name   = var.name
  description  = var.name
  features {
    # The image must have the NVMe driver built in before enabling this.
    nvme_support = "supported"
  }
  disk_device_mapping {
    oss_bucket      = alicloud_oss_bucket.default.id
    oss_object      = alicloud_oss_bucket_object.default.id
    disk_image_size = 5
  }
}

Need more examples? VIEW MORE EXAMPLES

Argument Reference

The following arguments are supported:

  • architecture - (Optional, ForceNew) The architecture of the image. Default value: x86_64. Valid values: x86_64, i386.

  • os_type - (Optional, ForceNew) The type of the operating system. Default value: linux. Valid values: windows, linux.

  • platform - (Optional, ForceNew) The operating system platform. More valid values refer to ImportImage OpenAPI.

    -> NOTE: Before provider version 1.197.0, the default value of platform is Ubuntu.

  • boot_mode - (Optional, ForceNew, Available since v1.225.0) The boot mode of the image. Valid values: BIOS, UEFI.

  • license_type - (Optional, ForceNew) The type of the license used to activate the operating system after the image is imported. Default value: Auto. Valid values: Auto, Aliyun, BYOL.

  • image_name - (Optional) The name of the image. The image_name must be 2 to 128 characters in length. The image_name must start with a letter and cannot start with acs: or aliyun. The image_name cannot contain http:// or https://. The image_name can contain letters, digits, periods (.), colons (:), underscores (_), and hyphens (-).

  • description - (Optional) The description of the image. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

  • disk_device_mapping - (Required, ForceNew, Set) The information about the custom image. See disk_device_mapping below.

  • features - (Optional, Computed) Features for the image. See features below.

disk_device_mapping

The disk_device_mapping supports the following:

  • format - (Optional, ForceNew) The format of the image. Valid values: RAW, VHD, qcow2.
  • oss_bucket - (Optional, ForceNew) The OSS bucket where the image file is stored.
  • oss_object - (Optional, ForceNew) The name (key) of the object that the uploaded image is stored as in the OSS bucket.
  • device - (Optional, ForceNew) The device name of the disk.
  • disk_image_size - (Optional, ForceNew, Int) The size of the disk. Default value: 5.

features

The features supports the following:

  • nvme_support - (Optional, Computed, Available since v1.294.0) Specifies whether to support the Non-Volatile Memory Express (NVMe) protocol. Valid values:

    • supported: The image supports NVMe. Instances created from this image also support NVMe.
    • unsupported: The image does not support NVMe. Instances created from this image do not support NVMe.

    -> NOTE: nvme_support only declares the capability of the image: setting it does not install the NVMe driver. The image must already have the NVMe driver built in before setting nvme_support to supported, otherwise instances created from the image may fail to boot. If this parameter is not set or is empty, it defaults to unsupported.

Attributes Reference

The following attributes are exported:

  • id - The resource ID in terraform of Image Import.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 20 mins) Used when create the Image Import.
  • delete - (Defaults to 20 mins) Used when delete the Image Import.

Import

ECS Image Import can be imported using the id, e.g.

$ terraform import alicloud_image_import.example <id>