1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. dns
  5. getManagedZone
Google Cloud Classic v7.16.0 published on Wednesday, Mar 27, 2024 by Pulumi

gcp.dns.getManagedZone

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.16.0 published on Wednesday, Mar 27, 2024 by Pulumi

    Provides access to a zone’s attributes within Google Cloud DNS. For more information see the official documentation and API.

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const envDnsZone = gcp.dns.getManagedZone({
        name: "qa-zone",
    });
    const dns = new gcp.dns.RecordSet("dns", {
        name: envDnsZone.then(envDnsZone => `my-address.${envDnsZone.dnsName}`),
        type: "TXT",
        ttl: 300,
        managedZone: envDnsZone.then(envDnsZone => envDnsZone.name),
        rrdatas: ["test"],
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    env_dns_zone = gcp.dns.get_managed_zone(name="qa-zone")
    dns = gcp.dns.RecordSet("dns",
        name=f"my-address.{env_dns_zone.dns_name}",
        type="TXT",
        ttl=300,
        managed_zone=env_dns_zone.name,
        rrdatas=["test"])
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-gcp/sdk/v7/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: "qa-zone",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = dns.NewRecordSet(ctx, "dns", &dns.RecordSetArgs{
    			Name:        pulumi.String(fmt.Sprintf("my-address.%v", envDnsZone.DnsName)),
    			Type:        pulumi.String("TXT"),
    			Ttl:         pulumi.Int(300),
    			ManagedZone: pulumi.String(envDnsZone.Name),
    			Rrdatas: pulumi.StringArray{
    				pulumi.String("test"),
    			},
    		})
    		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 = "qa-zone",
        });
    
        var dns = new Gcp.Dns.RecordSet("dns", new()
        {
            Name = $"my-address.{envDnsZone.Apply(getManagedZoneResult => getManagedZoneResult.DnsName)}",
            Type = "TXT",
            Ttl = 300,
            ManagedZone = envDnsZone.Apply(getManagedZoneResult => getManagedZoneResult.Name),
            Rrdatas = new[]
            {
                "test",
            },
        });
    
    });
    
    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.RecordSet;
    import com.pulumi.gcp.dns.RecordSetArgs;
    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("qa-zone")
                .build());
    
            var dns = new RecordSet("dns", RecordSetArgs.builder()        
                .name(String.format("my-address.%s", envDnsZone.applyValue(getManagedZoneResult -> getManagedZoneResult.dnsName())))
                .type("TXT")
                .ttl(300)
                .managedZone(envDnsZone.applyValue(getManagedZoneResult -> getManagedZoneResult.name()))
                .rrdatas("test")
                .build());
    
        }
    }
    
    resources:
      dns:
        type: gcp:dns:RecordSet
        properties:
          name: my-address.${envDnsZone.dnsName}
          type: TXT
          ttl: 300
          managedZone: ${envDnsZone.name}
          rrdatas:
            - test
    variables:
      envDnsZone:
        fn::invoke:
          Function: gcp:dns:getManagedZone
          Arguments:
            name: qa-zone
    

    Using getManagedZone

    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 getManagedZone(args: GetManagedZoneArgs, opts?: InvokeOptions): Promise<GetManagedZoneResult>
    function getManagedZoneOutput(args: GetManagedZoneOutputArgs, opts?: InvokeOptions): Output<GetManagedZoneResult>
    def get_managed_zone(name: Optional[str] = None,
                         project: Optional[str] = None,
                         opts: Optional[InvokeOptions] = None) -> GetManagedZoneResult
    def get_managed_zone_output(name: Optional[pulumi.Input[str]] = None,
                         project: Optional[pulumi.Input[str]] = None,
                         opts: Optional[InvokeOptions] = None) -> Output[GetManagedZoneResult]
    func LookupManagedZone(ctx *Context, args *LookupManagedZoneArgs, opts ...InvokeOption) (*LookupManagedZoneResult, error)
    func LookupManagedZoneOutput(ctx *Context, args *LookupManagedZoneOutputArgs, opts ...InvokeOption) LookupManagedZoneResultOutput

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

    public static class GetManagedZone 
    {
        public static Task<GetManagedZoneResult> InvokeAsync(GetManagedZoneArgs args, InvokeOptions? opts = null)
        public static Output<GetManagedZoneResult> Invoke(GetManagedZoneInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetManagedZoneResult> getManagedZone(GetManagedZoneArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: gcp:dns/getManagedZone:getManagedZone
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    A unique name for the resource.
    Project string
    The ID of the project for the Google Cloud DNS zone. If this is not provided the default project will be used.
    Name string
    A unique name for the resource.
    Project string
    The ID of the project for the Google Cloud DNS zone. If this is not provided the default project will be used.
    name String
    A unique name for the resource.
    project String
    The ID of the project for the Google Cloud DNS zone. If this is not provided the default project will be used.
    name string
    A unique name for the resource.
    project string
    The ID of the project for the Google Cloud DNS zone. If this is not provided the default project will be used.
    name str
    A unique name for the resource.
    project str
    The ID of the project for the Google Cloud DNS zone. If this is not provided the default project will be used.
    name String
    A unique name for the resource.
    project String
    The ID of the project for the Google Cloud DNS zone. If this is not provided the default project will be used.

    getManagedZone Result

    The following output properties are available:

    Description string
    A textual description field.
    DnsName string
    The fully qualified DNS name of this zone, e.g. example.io..
    Id string
    ManagedZoneId int
    Name string
    NameServers List<string>
    The list of nameservers that will be authoritative for this domain. Use NS records to redirect from your DNS provider to these names, thus making Google Cloud DNS authoritative for this zone.
    Visibility string
    The zone's visibility: public zones are exposed to the Internet, while private zones are visible only to Virtual Private Cloud resources.
    Project string
    Description string
    A textual description field.
    DnsName string
    The fully qualified DNS name of this zone, e.g. example.io..
    Id string
    ManagedZoneId int
    Name string
    NameServers []string
    The list of nameservers that will be authoritative for this domain. Use NS records to redirect from your DNS provider to these names, thus making Google Cloud DNS authoritative for this zone.
    Visibility string
    The zone's visibility: public zones are exposed to the Internet, while private zones are visible only to Virtual Private Cloud resources.
    Project string
    description String
    A textual description field.
    dnsName String
    The fully qualified DNS name of this zone, e.g. example.io..
    id String
    managedZoneId Integer
    name String
    nameServers List<String>
    The list of nameservers that will be authoritative for this domain. Use NS records to redirect from your DNS provider to these names, thus making Google Cloud DNS authoritative for this zone.
    visibility String
    The zone's visibility: public zones are exposed to the Internet, while private zones are visible only to Virtual Private Cloud resources.
    project String
    description string
    A textual description field.
    dnsName string
    The fully qualified DNS name of this zone, e.g. example.io..
    id string
    managedZoneId number
    name string
    nameServers string[]
    The list of nameservers that will be authoritative for this domain. Use NS records to redirect from your DNS provider to these names, thus making Google Cloud DNS authoritative for this zone.
    visibility string
    The zone's visibility: public zones are exposed to the Internet, while private zones are visible only to Virtual Private Cloud resources.
    project string
    description str
    A textual description field.
    dns_name str
    The fully qualified DNS name of this zone, e.g. example.io..
    id str
    managed_zone_id int
    name str
    name_servers Sequence[str]
    The list of nameservers that will be authoritative for this domain. Use NS records to redirect from your DNS provider to these names, thus making Google Cloud DNS authoritative for this zone.
    visibility str
    The zone's visibility: public zones are exposed to the Internet, while private zones are visible only to Virtual Private Cloud resources.
    project str
    description String
    A textual description field.
    dnsName String
    The fully qualified DNS name of this zone, e.g. example.io..
    id String
    managedZoneId Number
    name String
    nameServers List<String>
    The list of nameservers that will be authoritative for this domain. Use NS records to redirect from your DNS provider to these names, thus making Google Cloud DNS authoritative for this zone.
    visibility String
    The zone's visibility: public zones are exposed to the Internet, while private zones are visible only to Virtual Private Cloud resources.
    project String

    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
    Google Cloud Classic v7.16.0 published on Wednesday, Mar 27, 2024 by Pulumi