DigitalOcean v4.30.2 published on Wednesday, Jun 5, 2024 by Pulumi
digitalocean.getRecords
Explore with Pulumi AI
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:
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
import * as std from "@pulumi/std";
const example = digitalocean.getRecords({
    domain: "example.com",
    filters: [{
        key: "type",
        values: ["MX"],
    }],
});
export const mailServers = example.then(example => std.join({
    separator: ",",
    input: example.records.map(__item => __item.value),
})).then(invoke => invoke.result);
import pulumi
import pulumi_digitalocean as digitalocean
import pulumi_std as std
example = digitalocean.get_records(domain="example.com",
    filters=[digitalocean.GetRecordsFilterArgs(
        key="type",
        values=["MX"],
    )])
pulumi.export("mailServers", std.join(separator=",",
    input=[__item.value for __item in example.records]).result)
package main
import (
	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
	"github.com/pulumi/pulumi-std/sdk/go/std"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := digitalocean.GetRecords(ctx, &digitalocean.GetRecordsArgs{
Domain: "example.com",
Filters: []digitalocean.GetRecordsFilter{
{
Key: "type",
Values: []string{
"MX",
},
},
},
}, nil);
if err != nil {
return err
}
ctx.Export("mailServers", std.Join(ctx, var splat0 []*string
for _, val0 := range example.Records {
splat0 = append(splat0, val0.Value)
}
&std.JoinArgs{
Separator: ",",
Input: splat0,
}, nil).Result)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() => 
{
    var example = DigitalOcean.GetRecords.Invoke(new()
    {
        Domain = "example.com",
        Filters = new[]
        {
            new DigitalOcean.Inputs.GetRecordsFilterInputArgs
            {
                Key = "type",
                Values = new[]
                {
                    "MX",
                },
            },
        },
    });
    return new Dictionary<string, object?>
    {
        ["mailServers"] = Std.Join.Invoke(new()
        {
            Separator = ",",
            Input = example.Apply(getRecordsResult => getRecordsResult.Records).Select(__item => __item.Value).ToList(),
        }).Apply(invoke => invoke.Result),
    };
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.DigitaloceanFunctions;
import com.pulumi.digitalocean.inputs.GetRecordsArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        final var example = DigitaloceanFunctions.getRecords(GetRecordsArgs.builder()
            .domain("example.com")
            .filters(GetRecordsFilterArgs.builder()
                .key("type")
                .values("MX")
                .build())
            .build());
        ctx.export("mailServers", StdFunctions.join(JoinArgs.builder()
            .separator(",")
            .input(example.applyValue(getRecordsResult -> getRecordsResult.records()).stream().map(element -> element.value()).collect(toList()))
            .build()).result());
    }
}
Coming soon!
Using getRecords
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getRecords(args: GetRecordsArgs, opts?: InvokeOptions): Promise<GetRecordsResult>
function getRecordsOutput(args: GetRecordsOutputArgs, opts?: InvokeOptions): Output<GetRecordsResult>def get_records(domain: Optional[str] = None,
                filters: Optional[Sequence[GetRecordsFilter]] = None,
                sorts: Optional[Sequence[GetRecordsSort]] = None,
                opts: Optional[InvokeOptions] = None) -> GetRecordsResult
def get_records_output(domain: Optional[pulumi.Input[str]] = None,
                filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetRecordsFilterArgs]]]] = None,
                sorts: Optional[pulumi.Input[Sequence[pulumi.Input[GetRecordsSortArgs]]]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetRecordsResult]func GetRecords(ctx *Context, args *GetRecordsArgs, opts ...InvokeOption) (*GetRecordsResult, error)
func GetRecordsOutput(ctx *Context, args *GetRecordsOutputArgs, opts ...InvokeOption) GetRecordsResultOutput> Note: This function is named GetRecords in the Go SDK.
public static class GetRecords 
{
    public static Task<GetRecordsResult> InvokeAsync(GetRecordsArgs args, InvokeOptions? opts = null)
    public static Output<GetRecordsResult> Invoke(GetRecordsInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetRecordsResult> getRecords(GetRecordsArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: digitalocean:index/getRecords:getRecords
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Domain string
 - The domain name to search for DNS records
 - Filters
List<Pulumi.
Digital Ocean. Inputs. Get Records Filter>  - Filter the results.
The 
filterblock is documented below. - Sorts
List<Pulumi.
Digital Ocean. Inputs. Get Records Sort>  - Sort the results.
The 
sortblock is documented below. 
- Domain string
 - The domain name to search for DNS records
 - Filters
[]Get
Records Filter  - Filter the results.
The 
filterblock is documented below. - Sorts
[]Get
Records Sort  - Sort the results.
The 
sortblock is documented below. 
- domain String
 - The domain name to search for DNS records
 - filters
List<Get
Records Filter>  - Filter the results.
The 
filterblock is documented below. - sorts
List<Get
Records Sort>  - Sort the results.
The 
sortblock is documented below. 
- domain string
 - The domain name to search for DNS records
 - filters
Get
Records Filter[]  - Filter the results.
The 
filterblock is documented below. - sorts
Get
Records Sort[]  - Sort the results.
The 
sortblock is documented below. 
- domain str
 - The domain name to search for DNS records
 - filters
Sequence[Get
Records Filter]  - Filter the results.
The 
filterblock is documented below. - sorts
Sequence[Get
Records Sort]  - Sort the results.
The 
sortblock is documented below. 
- domain String
 - The domain name to search for DNS records
 - filters List<Property Map>
 - Filter the results.
The 
filterblock is documented below. - sorts List<Property Map>
 - Sort the results.
The 
sortblock is documented below. 
getRecords Result
The following output properties are available:
- Domain string
 - Domain of the DNS record.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Records
List<Pulumi.
Digital Ocean. Outputs. Get Records Record>  - Filters
List<Pulumi.
Digital Ocean. Outputs. Get Records Filter>  - Sorts
List<Pulumi.
Digital Ocean. Outputs. Get Records Sort>  
- Domain string
 - Domain of the DNS record.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Records
[]Get
Records Record  - Filters
[]Get
Records Filter  - Sorts
[]Get
Records Sort  
- domain String
 - Domain of the DNS record.
 - id String
 - The provider-assigned unique ID for this managed resource.
 - records
List<Get
Records Record>  - filters
List<Get
Records Filter>  - sorts
List<Get
Records Sort>  
- domain string
 - Domain of the DNS record.
 - id string
 - The provider-assigned unique ID for this managed resource.
 - records
Get
Records Record[]  - filters
Get
Records Filter[]  - sorts
Get
Records Sort[]  
- domain str
 - Domain of the DNS record.
 - id str
 - The provider-assigned unique ID for this managed resource.
 - records
Sequence[Get
Records Record]  - filters
Sequence[Get
Records Filter]  - sorts
Sequence[Get
Records Sort]  
- domain String
 - Domain of the DNS record.
 - id String
 - The provider-assigned unique ID for this managed resource.
 - records List<Property Map>
 - filters List<Property Map>
 - sorts List<Property Map>
 
Supporting Types
GetRecordsFilter  
- Key string
 - Filter the DNS records by this key. This may be one of 
domain,flags,name,port,priority,tag,ttl,type,value, orweight. - Values List<string>
 - A list of values to match against the 
keyfield. Only retrieves DNS records where thekeyfield takes on one or more of the values provided here. - All bool
 - Set to 
trueto 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. - Match
By string - One of 
exact(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. 
- Key string
 - Filter the DNS records by this key. This may be one of 
domain,flags,name,port,priority,tag,ttl,type,value, orweight. - Values []string
 - A list of values to match against the 
keyfield. Only retrieves DNS records where thekeyfield takes on one or more of the values provided here. - All bool
 - Set to 
trueto 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. - Match
By string - One of 
exact(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. 
- key String
 - Filter the DNS records by this key. This may be one of 
domain,flags,name,port,priority,tag,ttl,type,value, orweight. - values List<String>
 - A list of values to match against the 
keyfield. Only retrieves DNS records where thekeyfield takes on one or more of the values provided here. - all Boolean
 - Set to 
trueto 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. - match
By String - One of 
exact(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. 
- key string
 - Filter the DNS records by this key. This may be one of 
domain,flags,name,port,priority,tag,ttl,type,value, orweight. - values string[]
 - A list of values to match against the 
keyfield. Only retrieves DNS records where thekeyfield takes on one or more of the values provided here. - all boolean
 - Set to 
trueto 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. - match
By string - One of 
exact(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. 
- key str
 - Filter the DNS records by this key. This may be one of 
domain,flags,name,port,priority,tag,ttl,type,value, orweight. - values Sequence[str]
 - A list of values to match against the 
keyfield. Only retrieves DNS records where thekeyfield takes on one or more of the values provided here. - all bool
 - Set to 
trueto 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. - match_
by str - One of 
exact(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. 
- key String
 - Filter the DNS records by this key. This may be one of 
domain,flags,name,port,priority,tag,ttl,type,value, orweight. - values List<String>
 - A list of values to match against the 
keyfield. Only retrieves DNS records where thekeyfield takes on one or more of the values provided here. - all Boolean
 - Set to 
trueto 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. - match
By String - One of 
exact(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. 
GetRecordsRecord  
- Domain string
 - The domain name to search for DNS records
 - Flags int
 - An unsigned integer between 0-255 used for CAA records.
 - Id int
 - The ID of the record.
 - Name string
 - The name of the DNS record.
 - Port int
 - The port for SRV records.
 - Priority int
 - The priority for SRV and MX records.
 - Tag string
 - The parameter tag for CAA records.
 - Ttl int
 - 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.
 - Type string
 - The type of the DNS record.
 - Value string
 - 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.
 - Weight int
 - The weight for SRV records.
 
- Domain string
 - The domain name to search for DNS records
 - Flags int
 - An unsigned integer between 0-255 used for CAA records.
 - Id int
 - The ID of the record.
 - Name string
 - The name of the DNS record.
 - Port int
 - The port for SRV records.
 - Priority int
 - The priority for SRV and MX records.
 - Tag string
 - The parameter tag for CAA records.
 - Ttl int
 - 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.
 - Type string
 - The type of the DNS record.
 - Value string
 - 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.
 - Weight int
 - The weight for SRV records.
 
- domain String
 - The domain name to search for DNS records
 - flags Integer
 - An unsigned integer between 0-255 used for CAA records.
 - id Integer
 - The ID of the record.
 - name String
 - The name of the DNS record.
 - port Integer
 - The port for SRV records.
 - priority Integer
 - The priority for SRV and MX records.
 - tag String
 - The parameter tag for CAA records.
 - ttl Integer
 - 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.
 - type String
 - The type of the DNS record.
 - value String
 - 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.
 - weight Integer
 - The weight for SRV records.
 
- domain string
 - The domain name to search for DNS records
 - flags number
 - An unsigned integer between 0-255 used for CAA records.
 - id number
 - The ID of the record.
 - name string
 - The name of the DNS record.
 - port number
 - The port for SRV records.
 - priority number
 - The priority for SRV and MX records.
 - tag string
 - The parameter tag for CAA records.
 - ttl number
 - 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.
 - type string
 - The type of the DNS record.
 - value string
 - 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.
 - weight number
 - The weight for SRV records.
 
- domain str
 - The domain name to search for DNS records
 - flags int
 - An unsigned integer between 0-255 used for CAA records.
 - id int
 - The ID of the record.
 - name str
 - The name of the DNS record.
 - port int
 - The port for SRV records.
 - priority int
 - The priority for SRV and MX records.
 - tag str
 - The parameter tag for CAA records.
 - ttl int
 - 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.
 - type str
 - The type of the DNS record.
 - value str
 - 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.
 - weight int
 - The weight for SRV records.
 
- domain String
 - The domain name to search for DNS records
 - flags Number
 - An unsigned integer between 0-255 used for CAA records.
 - id Number
 - The ID of the record.
 - name String
 - The name of the DNS record.
 - port Number
 - The port for SRV records.
 - priority Number
 - The priority for SRV and MX records.
 - tag String
 - The parameter tag for CAA records.
 - ttl Number
 - 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.
 - type String
 - The type of the DNS record.
 - value String
 - 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.
 - weight Number
 - The weight for SRV records.
 
GetRecordsSort  
Package Details
- Repository
 - DigitalOcean pulumi/pulumi-digitalocean
 - License
 - Apache-2.0
 - Notes
 - This Pulumi package is based on the 
digitaloceanTerraform Provider.