digitalocean_records
Generated on 29 Jan 2026
from Terraform version
v2.75.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. Thefilterblock is documented below. -
sort- (Optional) Sort the results. Thesortblock 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 thekeyfield. Only retrieves DNS records where thekeyfield takes on one or more of the values provided here. -
match_by- (Optional) One ofexact(default),re, orsubstring. For string-typed fields, specifyreto match by using thevaluesas regular expressions, or specifysubstringto match by treating thevaluesas substrings to find within the string field. -
all- (Optional) Set totrueto require that a field match all of thevaluesinstead 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 thevaluesare 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 eitherascordesc.
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.