1. Packages
  2. Ibm Provider
  3. API Docs
  4. getDnsDomain
ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud

ibm.getDnsDomain

Explore with Pulumi AI

ibm logo
ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud

    Retrieve information of an existing domain as a read-only data source. For more information, about DNS resource, see managing DNS zones in classic infrastructure.

    Example Usage

    The following example shows how you can use the data source to reference the domain ID in the ibm.DnsRecord resource, as the numeric IDs are often unknown.

    import * as pulumi from "@pulumi/pulumi";
    import * as ibm from "@pulumi/ibm";
    
    const domainId = ibm.getDnsDomain({
        name: "test-domain.com",
    });
    const www = new ibm.DnsRecord("www", {domainId: domainId.then(domainId => domainId.id)});
    
    import pulumi
    import pulumi_ibm as ibm
    
    domain_id = ibm.get_dns_domain(name="test-domain.com")
    www = ibm.DnsRecord("www", domain_id=domain_id.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ibm/ibm"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		domainId, err := ibm.LookupDnsDomain(ctx, &ibm.LookupDnsDomainArgs{
    			Name: "test-domain.com",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = ibm.NewDnsRecord(ctx, "www", &ibm.DnsRecordArgs{
    			DomainId: pulumi.Float64(domainId.Id),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ibm = Pulumi.Ibm;
    
    return await Deployment.RunAsync(() => 
    {
        var domainId = Ibm.GetDnsDomain.Invoke(new()
        {
            Name = "test-domain.com",
        });
    
        var www = new Ibm.DnsRecord("www", new()
        {
            DomainId = domainId.Apply(getDnsDomainResult => getDnsDomainResult.Id),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ibm.IbmFunctions;
    import com.pulumi.ibm.inputs.GetDnsDomainArgs;
    import com.pulumi.ibm.DnsRecord;
    import com.pulumi.ibm.DnsRecordArgs;
    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 domainId = IbmFunctions.getDnsDomain(GetDnsDomainArgs.builder()
                .name("test-domain.com")
                .build());
    
            var www = new DnsRecord("www", DnsRecordArgs.builder()
                .domainId(domainId.applyValue(getDnsDomainResult -> getDnsDomainResult.id()))
                .build());
    
        }
    }
    
    resources:
      www:
        type: ibm:DnsRecord
        properties:
          domainId: ${domainId.id}
    variables:
      domainId:
        fn::invoke:
          function: ibm:getDnsDomain
          arguments:
            name: test-domain.com
    

    Using getDnsDomain

    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 getDnsDomain(args: GetDnsDomainArgs, opts?: InvokeOptions): Promise<GetDnsDomainResult>
    function getDnsDomainOutput(args: GetDnsDomainOutputArgs, opts?: InvokeOptions): Output<GetDnsDomainResult>
    def get_dns_domain(name: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetDnsDomainResult
    def get_dns_domain_output(name: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetDnsDomainResult]
    func LookupDnsDomain(ctx *Context, args *LookupDnsDomainArgs, opts ...InvokeOption) (*LookupDnsDomainResult, error)
    func LookupDnsDomainOutput(ctx *Context, args *LookupDnsDomainOutputArgs, opts ...InvokeOption) LookupDnsDomainResultOutput

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

    public static class GetDnsDomain 
    {
        public static Task<GetDnsDomainResult> InvokeAsync(GetDnsDomainArgs args, InvokeOptions? opts = null)
        public static Output<GetDnsDomainResult> Invoke(GetDnsDomainInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetDnsDomainResult> getDnsDomain(GetDnsDomainArgs args, InvokeOptions options)
    public static Output<GetDnsDomainResult> getDnsDomain(GetDnsDomainArgs args, InvokeOptions options)
    
    fn::invoke:
      function: ibm:index/getDnsDomain:getDnsDomain
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    The name of the domain, as defined in IBM Cloud Classic Infrastructure (SoftLayer).
    Name string
    The name of the domain, as defined in IBM Cloud Classic Infrastructure (SoftLayer).
    name String
    The name of the domain, as defined in IBM Cloud Classic Infrastructure (SoftLayer).
    name string
    The name of the domain, as defined in IBM Cloud Classic Infrastructure (SoftLayer).
    name str
    The name of the domain, as defined in IBM Cloud Classic Infrastructure (SoftLayer).
    name String
    The name of the domain, as defined in IBM Cloud Classic Infrastructure (SoftLayer).

    getDnsDomain Result

    The following output properties are available:

    Id double
    (String) The unique identifier of the domain.
    Name string
    Id float64
    (String) The unique identifier of the domain.
    Name string
    id Double
    (String) The unique identifier of the domain.
    name String
    id number
    (String) The unique identifier of the domain.
    name string
    id float
    (String) The unique identifier of the domain.
    name str
    id Number
    (String) The unique identifier of the domain.
    name String

    Package Details

    Repository
    ibm ibm-cloud/terraform-provider-ibm
    License
    Notes
    This Pulumi package is based on the ibm Terraform Provider.
    ibm logo
    ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud