digitalocean_image

Get information on an image for use in other resources (e.g. creating a Droplet based on snapshot). This data source provides all of the image properties as configured on your DigitalOcean account. This is useful if the image in question is not managed by Terraform or you need to utilize any of the image's data.

An error is triggered if zero or more than one result is returned by the query.

Example Usage

Get the data about a snapshot:

data "digitalocean_image" "example1" {
  name = "example-1.0.0"
}

Reuse the data about a snapshot to create a Droplet:

data "digitalocean_image" "example" {
  name = "example-1.0.0"
}

resource "digitalocean_droplet" "example" {
  image  = data.digitalocean_image.example.id
  name   = "example-1"
  region = "nyc2"
  size   = "s-1vcpu-1gb"
}

Get the data about an official image:

data "digitalocean_image" "example2" {
  slug = "ubuntu-18-04-x64"
}

Argument Reference

One of the following arguments must be provided:

If name is specified, you may also specify:

Attributes Reference

The following attributes are exported: