1. Packages
  2. DigitalOcean Provider
  3. API Docs
  4. getDomains
DigitalOcean v4.42.0 published on Thursday, Apr 17, 2025 by Pulumi

digitalocean.getDomains

Explore with Pulumi AI

DigitalOcean v4.42.0 published on Thursday, Apr 17, 2025 by Pulumi

Get information on domains for use in other resources, with the ability to filter and sort the results. If no filters are specified, all domains will be returned.

This data source is useful if the domains in question are not managed by this provider or you need to utilize any of the domains’ data.

Note: You can use the digitalocean.Domain data source to obtain metadata about a single domain if you already know the name.

Example Usage

Use the filter block with a key string and values list to filter domains. (This example also uses the regular expression match_by mode in order to match domains by suffix.)

import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const examples = digitalocean.getDomains({
    filters: [{
        key: "name",
        values: ["example\\.com$"],
        matchBy: "re",
    }],
});
Copy
import pulumi
import pulumi_digitalocean as digitalocean

examples = digitalocean.get_domains(filters=[{
    "key": "name",
    "values": ["example\\.com$"],
    "match_by": "re",
}])
Copy
package main

import (
	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := digitalocean.GetDomains(ctx, &digitalocean.GetDomainsArgs{
			Filters: []digitalocean.GetDomainsFilter{
				{
					Key: "name",
					Values: []string{
						"example\\.com$",
					},
					MatchBy: pulumi.StringRef("re"),
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var examples = DigitalOcean.GetDomains.Invoke(new()
    {
        Filters = new[]
        {
            new DigitalOcean.Inputs.GetDomainsFilterInputArgs
            {
                Key = "name",
                Values = new[]
                {
                    "example\\.com$",
                },
                MatchBy = "re",
            },
        },
    });

});
Copy
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.GetDomainsArgs;
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 examples = DigitaloceanFunctions.getDomains(GetDomainsArgs.builder()
            .filters(GetDomainsFilterArgs.builder()
                .key("name")
                .values("example\\.com$")
                .matchBy("re")
                .build())
            .build());

    }
}
Copy
variables:
  examples:
    fn::invoke:
      function: digitalocean:getDomains
      arguments:
        filters:
          - key: name
            values:
              - example\.com$
            matchBy: re
Copy

Using getDomains

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 getDomains(args: GetDomainsArgs, opts?: InvokeOptions): Promise<GetDomainsResult>
function getDomainsOutput(args: GetDomainsOutputArgs, opts?: InvokeOptions): Output<GetDomainsResult>
Copy
def get_domains(filters: Optional[Sequence[GetDomainsFilter]] = None,
                sorts: Optional[Sequence[GetDomainsSort]] = None,
                opts: Optional[InvokeOptions] = None) -> GetDomainsResult
def get_domains_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetDomainsFilterArgs]]]] = None,
                sorts: Optional[pulumi.Input[Sequence[pulumi.Input[GetDomainsSortArgs]]]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetDomainsResult]
Copy
func GetDomains(ctx *Context, args *GetDomainsArgs, opts ...InvokeOption) (*GetDomainsResult, error)
func GetDomainsOutput(ctx *Context, args *GetDomainsOutputArgs, opts ...InvokeOption) GetDomainsResultOutput
Copy

> Note: This function is named GetDomains in the Go SDK.

public static class GetDomains 
{
    public static Task<GetDomainsResult> InvokeAsync(GetDomainsArgs args, InvokeOptions? opts = null)
    public static Output<GetDomainsResult> Invoke(GetDomainsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetDomainsResult> getDomains(GetDomainsArgs args, InvokeOptions options)
public static Output<GetDomainsResult> getDomains(GetDomainsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: digitalocean:index/getDomains:getDomains
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Filters List<Pulumi.DigitalOcean.Inputs.GetDomainsFilter>
Filter the results. The filter block is documented below.
Sorts List<Pulumi.DigitalOcean.Inputs.GetDomainsSort>
Sort the results. The sort block is documented below.
Filters []GetDomainsFilter
Filter the results. The filter block is documented below.
Sorts []GetDomainsSort
Sort the results. The sort block is documented below.
filters List<GetDomainsFilter>
Filter the results. The filter block is documented below.
sorts List<GetDomainsSort>
Sort the results. The sort block is documented below.
filters GetDomainsFilter[]
Filter the results. The filter block is documented below.
sorts GetDomainsSort[]
Sort the results. The sort block is documented below.
filters Sequence[GetDomainsFilter]
Filter the results. The filter block is documented below.
sorts Sequence[GetDomainsSort]
Sort the results. The sort block is documented below.
filters List<Property Map>
Filter the results. The filter block is documented below.
sorts List<Property Map>
Sort the results. The sort block is documented below.

getDomains Result

The following output properties are available:

Domains List<Pulumi.DigitalOcean.Outputs.GetDomainsDomain>
A list of domains satisfying any filter and sort criteria. Each domain has the following attributes:
Id string
The provider-assigned unique ID for this managed resource.
Filters List<Pulumi.DigitalOcean.Outputs.GetDomainsFilter>
Sorts List<Pulumi.DigitalOcean.Outputs.GetDomainsSort>
Domains []GetDomainsDomain
A list of domains satisfying any filter and sort criteria. Each domain has the following attributes:
Id string
The provider-assigned unique ID for this managed resource.
Filters []GetDomainsFilter
Sorts []GetDomainsSort
domains List<GetDomainsDomain>
A list of domains satisfying any filter and sort criteria. Each domain has the following attributes:
id String
The provider-assigned unique ID for this managed resource.
filters List<GetDomainsFilter>
sorts List<GetDomainsSort>
domains GetDomainsDomain[]
A list of domains satisfying any filter and sort criteria. Each domain has the following attributes:
id string
The provider-assigned unique ID for this managed resource.
filters GetDomainsFilter[]
sorts GetDomainsSort[]
domains Sequence[GetDomainsDomain]
A list of domains satisfying any filter and sort criteria. Each domain has the following attributes:
id str
The provider-assigned unique ID for this managed resource.
filters Sequence[GetDomainsFilter]
sorts Sequence[GetDomainsSort]
domains List<Property Map>
A list of domains satisfying any filter and sort criteria. Each domain has the following attributes:
id String
The provider-assigned unique ID for this managed resource.
filters List<Property Map>
sorts List<Property Map>

Supporting Types

GetDomainsDomain

Name This property is required. string
(Required) The name of the domain.
Ttl This property is required. int
The TTL of the domain.
Urn This property is required. string
The uniform resource name of the domain
Name This property is required. string
(Required) The name of the domain.
Ttl This property is required. int
The TTL of the domain.
Urn This property is required. string
The uniform resource name of the domain
name This property is required. String
(Required) The name of the domain.
ttl This property is required. Integer
The TTL of the domain.
urn This property is required. String
The uniform resource name of the domain
name This property is required. string
(Required) The name of the domain.
ttl This property is required. number
The TTL of the domain.
urn This property is required. string
The uniform resource name of the domain
name This property is required. str
(Required) The name of the domain.
ttl This property is required. int
The TTL of the domain.
urn This property is required. str
The uniform resource name of the domain
name This property is required. String
(Required) The name of the domain.
ttl This property is required. Number
The TTL of the domain.
urn This property is required. String
The uniform resource name of the domain

GetDomainsFilter

Key This property is required. string
Filter the domains by this key. This may be one of name, urn, and ttl.
Values This property is required. List<string>
A list of values to match against the key field. Only retrieves domains where the key field takes on one or more of the values provided here.
All bool
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.
MatchBy string
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.
Key This property is required. string
Filter the domains by this key. This may be one of name, urn, and ttl.
Values This property is required. []string
A list of values to match against the key field. Only retrieves domains where the key field takes on one or more of the values provided here.
All bool
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.
MatchBy string
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.
key This property is required. String
Filter the domains by this key. This may be one of name, urn, and ttl.
values This property is required. List<String>
A list of values to match against the key field. Only retrieves domains where the key field takes on one or more of the values provided here.
all Boolean
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.
matchBy String
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.
key This property is required. string
Filter the domains by this key. This may be one of name, urn, and ttl.
values This property is required. string[]
A list of values to match against the key field. Only retrieves domains where the key field takes on one or more of the values provided here.
all boolean
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.
matchBy string
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.
key This property is required. str
Filter the domains by this key. This may be one of name, urn, and ttl.
values This property is required. Sequence[str]
A list of values to match against the key field. Only retrieves domains where the key field takes on one or more of the values provided here.
all bool
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.
match_by str
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.
key This property is required. String
Filter the domains by this key. This may be one of name, urn, and ttl.
values This property is required. List<String>
A list of values to match against the key field. Only retrieves domains where the key field takes on one or more of the values provided here.
all Boolean
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.
matchBy String
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.

GetDomainsSort

Key This property is required. string
Sort the domains by this key. This may be one of name, urn, and ttl.
Direction string
The sort direction. This may be either asc or desc.
Key This property is required. string
Sort the domains by this key. This may be one of name, urn, and ttl.
Direction string
The sort direction. This may be either asc or desc.
key This property is required. String
Sort the domains by this key. This may be one of name, urn, and ttl.
direction String
The sort direction. This may be either asc or desc.
key This property is required. string
Sort the domains by this key. This may be one of name, urn, and ttl.
direction string
The sort direction. This may be either asc or desc.
key This property is required. str
Sort the domains by this key. This may be one of name, urn, and ttl.
direction str
The sort direction. This may be either asc or desc.
key This property is required. String
Sort the domains by this key. This may be one of name, urn, and ttl.
direction String
The sort direction. This may be either asc or desc.

Package Details

Repository
DigitalOcean pulumi/pulumi-digitalocean
License
Apache-2.0
Notes
This Pulumi package is based on the digitalocean Terraform Provider.
DigitalOcean v4.42.0 published on Thursday, Apr 17, 2025 by Pulumi