Get information on Droplets for use in other resources, with the ability to filter and sort the results. If no filters are specified, all Droplets will be returned.
This data source is useful if the Droplets in question are not managed by Terraform or you need to utilize any of the Droplets’ data.
By default, only non-GPU Droplets are returned. To list only GPU Droplets, set
the gpus
attribute to true
.
Note: You can use the digitalocean_droplet
data source to obtain metadata
about a single Droplet if you already know the id
, unique name
, or unique tag
to retrieve.
Use the filter
block with a key
string and values
list to filter images.
For example to find all Droplets with size s-1vcpu-1gb
:
data "digitalocean_droplets" "small" {
filter {
key = "size"
values = ["s-1vcpu-1gb"]
}
}
You can filter on multiple fields and sort the results as well:
data "digitalocean_droplets" "small-with-backups" {
filter {
key = "size"
values = ["s-1vcpu-1gb"]
}
filter {
key = "backups"
values = ["true"]
}
sort {
key = "created_at"
direction = "desc"
}
}
gpus
- (Optional) A boolean value specifying whether or not to list GPU Droplets
filter
- (Optional) Filter the results.
The filter
block is documented below.
sort
- (Optional) Sort the results.
The sort
block is documented below.
filter
supports the following arguments:
key
- (Required) Filter the Droplets by this key. This may be one of backups
, created_at
, disk
, id
,
image
, ipv4_address
, ipv4_address_private
, ipv6
, ipv6_address
, ipv6_address_private
, locked
,
memory
, monitoring
, name
, price_hourly
, price_monthly
, private_networking
, region
, size
,
status
, tags
, urn
, vcpus
, volume_ids
, or vpc_uuid
.
values
- (Required) A list of values to match against the key
field. Only retrieves Droplets
where the key
field takes on one or more of the values provided here.
match_by
- (Optional) One of exact
(default), re
, or substring
. For string-typed fields, specify re
to
match by using the values
as regular expressions, or specify substring
to match by treating the values
as
substrings to find within the string field.
all
- (Optional) Set to true
to require that a field match all of the values
instead of just one or more of
them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure
that all of the values
are present in the list or set.
sort
supports the following arguments:
key
- (Required) Sort the Droplets by this key. This may be one of backups
, created_at
, disk
, id
,
image
, ipv4_address
, ipv4_address_private
, ipv6
, ipv6_address
, ipv6_address_private
, locked
,
memory
, monitoring
, name
, price_hourly
, price_monthly
, private_networking
, region
, size
,
status
, urn
, vcpus
, or vpc_uuid
.
direction
- (Required) The sort direction. This may be either asc
or desc
.
droplets
- A list of Droplets satisfying any filter
and sort
criteria. Each Droplet has the following attributes:
id
- The ID of the Droplet.urn
- The uniform resource name of the Dropletregion
- The region the Droplet is running in.image
- The Droplet image ID or slug.size
- The unique slug that identifies the type of Droplet.disk
- The size of the Droplet’s disk in GB.vcpus
- The number of the Droplet’s virtual CPUs.memory
- The amount of the Droplet’s memory in MB.price_hourly
- Droplet hourly price.price_monthly
- Droplet monthly price.status
- The status of the Droplet.locked
- Whether the Droplet is locked.ipv6_address
- The Droplet’s public IPv6 addressipv6_address_private
- The Droplet’s private IPv6 addressipv4_address
- The Droplet’s public IPv4 addressipv4_address_private
- The Droplet’s private IPv4 addressbackups
- Whether backups are enabled.ipv6
- Whether IPv6 is enabled.private_networking
- Whether private networks are enabled.monitoring
- Whether monitoring agent is installed.volume_ids
- List of the IDs of each volumes attached to the Droplet.tags
- A list of the tags associated to the Droplet.vpc_uuid
- The ID of the VPC where the Droplet is located.