digitalocean_records
Generated on 16 Jun 2025
from Terraform version
v2.56.0
Retrieve information about all DNS records within a domain, with the ability to filter and sort the results. If no filters are specified, all records will be returned.
Example Usage
Get data for all MX records in a domain:
data "digitalocean_records" "example" {
domain = "example.com"
filter {
key = "type"
values = ["MX"]
}
}
output "mail_servers" {
value = join(",", data.digitalocean_records.example.records[*].value)
}
Argument Reference
The following arguments are supported:
-
domain
- (Required) The domain name to search for DNS records -
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 DNS records by this key. This may be one ofdomain
,flags
,name
,port
,priority
,tag
,ttl
,type
,value
, orweight
. -
values
- (Required) A list of values to match against thekey
field. Only retrieves DNS records 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 DNS records by this key. This may be one ofdomain
,flags
,name
,port
,priority
,tag
,ttl
,type
,value
, orweight
.direction
- (Required) The sort direction. This may be eitherasc
ordesc
.
Attributes Reference
The following attributes are exported:
id
: The ID of the record.domain
: Domain of the DNS record.name
: The name of the DNS record.type
: The type of the DNS record.value
: Variable data depending on record type. For example, the “data” value for an A record would be the IPv4 address to which the domain will be mapped. For a CAA record, it would contain the domain name of the CA being granted permission to issue certificates.priority
: The priority for SRV and MX records.port
: The port for SRV records.ttl
: This value is the time to live for the record, in seconds. This defines the time frame that clients can cache queried information before a refresh should be requested.weight
: The weight for SRV records.flags
: An unsigned integer between 0-255 used for CAA records.tag
: The parameter tag for CAA records.