digitalocean_droplets
Generated on 17 Apr 2025
from Terraform version
v2.51.0
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.
Example Usage
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"
}
}
Argument Reference
-
gpus
- (Optional) A boolean value specifying whether or not to list GPU Droplets -
filter
- (Optional) Filter the results. Thefilter
block is documented below. -
sort
- (Optional) Sort the results. Thesort
block is documented below.
filter
supports the following arguments:
-
key
- (Required) Filter the Droplets by this key. This may be one ofbackups
,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
, orvpc_uuid
. -
values
- (Required) A list of values to match against thekey
field. Only retrieves Droplets where thekey
field takes on one or more of the values provided here. -
match_by
- (Optional) One ofexact
(default),re
, orsubstring
. For string-typed fields, specifyre
to match by using thevalues
as regular expressions, or specifysubstring
to match by treating thevalues
as substrings to find within the string field. -
all
- (Optional) Set totrue
to require that a field match all of thevalues
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 thevalues
are present in the list or set.
sort
supports the following arguments:
-
key
- (Required) Sort the Droplets by this key. This may be one ofbackups
,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
, orvpc_uuid
. -
direction
- (Required) The sort direction. This may be eitherasc
ordesc
.
Attributes Reference
-
droplets
- A list of Droplets satisfying anyfilter
andsort
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.