1. Packages
  2. Packages
  3. Google Cloud (GCP) Classic
  4. API Docs
  5. dns
  6. getRecordSets
Viewing docs for Google Cloud v9.23.0
published on Thursday, May 7, 2026 by Pulumi
gcp logo
Viewing docs for Google Cloud v9.23.0
published on Thursday, May 7, 2026 by Pulumi

    Get a list of DNS record sets within a Google Cloud DNS managed zone. This data source allows you to list all record sets or filter them by name and type.

    To get more information about Cloud DNS Record Sets, see:

    Note: Filtering by type when name is not set is performed client-side.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const envDnsZone = gcp.dns.getManagedZone({
        name: "my-zone-name",
    });
    const example = envDnsZone.then(envDnsZone => gcp.dns.getRecordSets({
        managedZone: envDnsZone.name,
        type: "A",
    }));
    
    import pulumi
    import pulumi_gcp as gcp
    
    env_dns_zone = gcp.dns.get_managed_zone(name="my-zone-name")
    example = gcp.dns.get_record_sets(managed_zone=env_dns_zone.name,
        type="A")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/dns"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		envDnsZone, err := dns.LookupManagedZone(ctx, &dns.LookupManagedZoneArgs{
    			Name: "my-zone-name",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = dns.GetRecordSets(ctx, &dns.GetRecordSetsArgs{
    			ManagedZone: envDnsZone.Name,
    			Type:        pulumi.StringRef("A"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var envDnsZone = Gcp.Dns.GetManagedZone.Invoke(new()
        {
            Name = "my-zone-name",
        });
    
        var example = Gcp.Dns.GetRecordSets.Invoke(new()
        {
            ManagedZone = envDnsZone.Apply(getManagedZoneResult => getManagedZoneResult.Name),
            Type = "A",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.dns.DnsFunctions;
    import com.pulumi.gcp.dns.inputs.GetManagedZoneArgs;
    import com.pulumi.gcp.dns.inputs.GetRecordSetsArgs;
    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 envDnsZone = DnsFunctions.getManagedZone(GetManagedZoneArgs.builder()
                .name("my-zone-name")
                .build());
    
            final var example = DnsFunctions.getRecordSets(GetRecordSetsArgs.builder()
                .managedZone(envDnsZone.name())
                .type("A")
                .build());
    
        }
    }
    
    variables:
      envDnsZone:
        fn::invoke:
          function: gcp:dns:getManagedZone
          arguments:
            name: my-zone-name
      example:
        fn::invoke:
          function: gcp:dns:getRecordSets
          arguments:
            managedZone: ${envDnsZone.name}
            type: A
    
    Example coming soon!
    

    Using getRecordSets

    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 getRecordSets(args: GetRecordSetsArgs, opts?: InvokeOptions): Promise<GetRecordSetsResult>
    function getRecordSetsOutput(args: GetRecordSetsOutputArgs, opts?: InvokeOptions): Output<GetRecordSetsResult>
    def get_record_sets(managed_zone: Optional[str] = None,
                        name: Optional[str] = None,
                        project: Optional[str] = None,
                        type: Optional[str] = None,
                        opts: Optional[InvokeOptions] = None) -> GetRecordSetsResult
    def get_record_sets_output(managed_zone: pulumi.Input[Optional[str]] = None,
                        name: pulumi.Input[Optional[str]] = None,
                        project: pulumi.Input[Optional[str]] = None,
                        type: pulumi.Input[Optional[str]] = None,
                        opts: Optional[InvokeOptions] = None) -> Output[GetRecordSetsResult]
    func GetRecordSets(ctx *Context, args *GetRecordSetsArgs, opts ...InvokeOption) (*GetRecordSetsResult, error)
    func GetRecordSetsOutput(ctx *Context, args *GetRecordSetsOutputArgs, opts ...InvokeOption) GetRecordSetsResultOutput

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

    public static class GetRecordSets 
    {
        public static Task<GetRecordSetsResult> InvokeAsync(GetRecordSetsArgs args, InvokeOptions? opts = null)
        public static Output<GetRecordSetsResult> Invoke(GetRecordSetsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetRecordSetsResult> getRecordSets(GetRecordSetsArgs args, InvokeOptions options)
    public static Output<GetRecordSetsResult> getRecordSets(GetRecordSetsArgs args, InvokeOptions options)
    
    fn::invoke:
      function: gcp:dns/getRecordSets:getRecordSets
      arguments:
        # arguments dictionary
    data "gcp_dns_getrecordsets" "name" {
        # arguments
    }

    The following arguments are supported:

    ManagedZone string
    The name of the managed zone to fetch the record sets from.
    Name string
    The name of the record set to filter by.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    Type string
    The type of the record set to filter by.
    ManagedZone string
    The name of the managed zone to fetch the record sets from.
    Name string
    The name of the record set to filter by.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    Type string
    The type of the record set to filter by.
    managed_zone string
    The name of the managed zone to fetch the record sets from.
    name string
    The name of the record set to filter by.
    project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    type string
    The type of the record set to filter by.
    managedZone String
    The name of the managed zone to fetch the record sets from.
    name String
    The name of the record set to filter by.
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    type String
    The type of the record set to filter by.
    managedZone string
    The name of the managed zone to fetch the record sets from.
    name string
    The name of the record set to filter by.
    project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    type string
    The type of the record set to filter by.
    managed_zone str
    The name of the managed zone to fetch the record sets from.
    name str
    The name of the record set to filter by.
    project str
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    type str
    The type of the record set to filter by.
    managedZone String
    The name of the managed zone to fetch the record sets from.
    name String
    The name of the record set to filter by.
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    type String
    The type of the record set to filter by.

    getRecordSets Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    ManagedZone string
    Rrsets List<GetRecordSetsRrset>
    A list of record sets in the selected managed zone matching the filter. Structure is defined below.
    Name string
    The name of the record set.
    Project string
    Type string
    The type of the record set.
    Id string
    The provider-assigned unique ID for this managed resource.
    ManagedZone string
    Rrsets []GetRecordSetsRrset
    A list of record sets in the selected managed zone matching the filter. Structure is defined below.
    Name string
    The name of the record set.
    Project string
    Type string
    The type of the record set.
    id string
    The provider-assigned unique ID for this managed resource.
    managed_zone string
    rrsets list(object)
    A list of record sets in the selected managed zone matching the filter. Structure is defined below.
    name string
    The name of the record set.
    project string
    type string
    The type of the record set.
    id String
    The provider-assigned unique ID for this managed resource.
    managedZone String
    rrsets List<GetRecordSetsRrset>
    A list of record sets in the selected managed zone matching the filter. Structure is defined below.
    name String
    The name of the record set.
    project String
    type String
    The type of the record set.
    id string
    The provider-assigned unique ID for this managed resource.
    managedZone string
    rrsets GetRecordSetsRrset[]
    A list of record sets in the selected managed zone matching the filter. Structure is defined below.
    name string
    The name of the record set.
    project string
    type string
    The type of the record set.
    id str
    The provider-assigned unique ID for this managed resource.
    managed_zone str
    rrsets Sequence[GetRecordSetsRrset]
    A list of record sets in the selected managed zone matching the filter. Structure is defined below.
    name str
    The name of the record set.
    project str
    type str
    The type of the record set.
    id String
    The provider-assigned unique ID for this managed resource.
    managedZone String
    rrsets List<Property Map>
    A list of record sets in the selected managed zone matching the filter. Structure is defined below.
    name String
    The name of the record set.
    project String
    type String
    The type of the record set.

    Supporting Types

    GetRecordSetsRrset

    Name string
    The name of the record set to filter by.
    Rrdatas List<string>
    A list of the record set's data (e.g., IP addresses, target names).
    Ttl int
    The time-to-live of this record set (seconds).
    Type string
    The type of the record set to filter by.
    Name string
    The name of the record set to filter by.
    Rrdatas []string
    A list of the record set's data (e.g., IP addresses, target names).
    Ttl int
    The time-to-live of this record set (seconds).
    Type string
    The type of the record set to filter by.
    name string
    The name of the record set to filter by.
    rrdatas list(string)
    A list of the record set's data (e.g., IP addresses, target names).
    ttl number
    The time-to-live of this record set (seconds).
    type string
    The type of the record set to filter by.
    name String
    The name of the record set to filter by.
    rrdatas List<String>
    A list of the record set's data (e.g., IP addresses, target names).
    ttl Integer
    The time-to-live of this record set (seconds).
    type String
    The type of the record set to filter by.
    name string
    The name of the record set to filter by.
    rrdatas string[]
    A list of the record set's data (e.g., IP addresses, target names).
    ttl number
    The time-to-live of this record set (seconds).
    type string
    The type of the record set to filter by.
    name str
    The name of the record set to filter by.
    rrdatas Sequence[str]
    A list of the record set's data (e.g., IP addresses, target names).
    ttl int
    The time-to-live of this record set (seconds).
    type str
    The type of the record set to filter by.
    name String
    The name of the record set to filter by.
    rrdatas List<String>
    A list of the record set's data (e.g., IP addresses, target names).
    ttl Number
    The time-to-live of this record set (seconds).
    type String
    The type of the record set to filter by.

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the google-beta Terraform Provider.
    gcp logo
    Viewing docs for Google Cloud v9.23.0
    published on Thursday, May 7, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.