dtcloud_image (Data Source)
Looks up one image, by id or by name.
Use it to reference an image Terraform did not upload: one from the platform's own catalogue, or one somebody built by hand. Declaring such an image as a resource would hand Terraform ownership of it, and a later destroy would delete it.
Example Usage
# By name. The lookup refuses an ambiguous answer rather than picking the first
# match, because image names are not unique on the platform.
data "dtcloud_image" "ubuntu" {
name = "Ubuntu 22.04"
}
data "dtcloud_image" "by_id" {
id = var.image_id
}
Schema
Optional
id(String) ID of the image to look up. Give this orname.name(String) Name of the image to look up. Give this orid. It is an error for more than one image to carry the name.
Read-Only
min_disk(Number) Smallest volume, in GB, a machine built from this image needs.0when the platform reports none.os_distro(String) Distribution the image carries.os_type(String)linuxorwindows, when the platform reports it. Frequently empty here: the details endpoint passes the value straight through, while the list endpoint behinddtcloud_imagesguesses it fromos_distrowhen it is missing.size(String) Size of the captured data, as the platform formats it —1.2 GBor250 MB. There is no endpoint that reports it as a number. An image with no data yet reads as0 MB.status(String) Status reported by the platform.activeis the only status a machine can be built from;queuedandsavingmean the data is not there yet, andkilledmeans the capture failed.type(String) How the platform categorises the image:ISOorTemplate (VM). This is notdisk_format— it is derived from it, and the two are not interchangeable.uefi(Boolean) Whether the image boots with UEFI firmware rather than BIOS.visibility(String) Who can see the image:public,private,sharedorcommunity.
Behaviour worth knowing
- A name must match exactly one image. Image names are not unique on the platform. A lookup that matches several fails and lists the matching ids, rather than building machines from an image nobody chose.
- Both lookups end on the details endpoint, so the same fields come back however the image was
found. That endpoint often reports an empty
os_type;dtcloud_imagesfills it in fromos_distro. - An image that does not exist is an error, not an empty result.