1. Packages
  2. Digitalocean Provider
  3. API Docs
  4. getRecord
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

digitalocean.getRecord

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Get information on a DNS record. This data source provides the name, TTL, and zone file as configured on your DigitalOcean account. This is useful if the record in question is not managed by the provider.

    An error is triggered if the provided domain name or record are not managed with your DigitalOcean account.

    Example Usage

    Get data from a DNS record:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const example = digitalocean.getRecord({
        domain: "example.com",
        name: "test",
    });
    export const recordType = example.then(example => example.type);
    export const recordTtl = example.then(example => example.ttl);
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    example = digitalocean.get_record(domain="example.com",
        name="test")
    pulumi.export("recordType", example.type)
    pulumi.export("recordTtl", example.ttl)
    
    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 {
    		example, err := digitalocean.GetRecord(ctx, &digitalocean.GetRecordArgs{
    			Domain: "example.com",
    			Name:   "test",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("recordType", example.Type)
    		ctx.Export("recordTtl", example.Ttl)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        var example = DigitalOcean.GetRecord.Invoke(new()
        {
            Domain = "example.com",
            Name = "test",
        });
    
        return new Dictionary<string, object?>
        {
            ["recordType"] = example.Apply(getRecordResult => getRecordResult.Type),
            ["recordTtl"] = example.Apply(getRecordResult => getRecordResult.Ttl),
        };
    });
    
    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.GetRecordArgs;
    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.getRecord(GetRecordArgs.builder()
                .domain("example.com")
                .name("test")
                .build());
    
            ctx.export("recordType", example.applyValue(getRecordResult -> getRecordResult.type()));
            ctx.export("recordTtl", example.applyValue(getRecordResult -> getRecordResult.ttl()));
        }
    }
    
    variables:
      example:
        fn::invoke:
          Function: digitalocean:getRecord
          Arguments:
            domain: example.com
            name: test
    outputs:
      recordType: ${example.type}
      recordTtl: ${example.ttl}
    
    
    data.digitalocean_record.example: Refreshing state...
    
    Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
    
    Outputs:
    
    record_ttl = 3600
    record_type = A
    

    Using getRecord

    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 getRecord(args: GetRecordArgs, opts?: InvokeOptions): Promise<GetRecordResult>
    function getRecordOutput(args: GetRecordOutputArgs, opts?: InvokeOptions): Output<GetRecordResult>
    def get_record(domain: Optional[str] = None,
                   name: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetRecordResult
    def get_record_output(domain: Optional[pulumi.Input[str]] = None,
                   name: Optional[pulumi.Input[str]] = None,
                   opts: Optional[InvokeOptions] = None) -> Output[GetRecordResult]
    func GetRecord(ctx *Context, args *GetRecordArgs, opts ...InvokeOption) (*GetRecordResult, error)
    func GetRecordOutput(ctx *Context, args *GetRecordOutputArgs, opts ...InvokeOption) GetRecordResultOutput

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

    public static class GetRecord 
    {
        public static Task<GetRecordResult> InvokeAsync(GetRecordArgs args, InvokeOptions? opts = null)
        public static Output<GetRecordResult> Invoke(GetRecordInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetRecordResult> getRecord(GetRecordArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: digitalocean:index/getRecord:getRecord
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Domain string
    The domain name of the record.
    Name string
    The name of the record.
    Domain string
    The domain name of the record.
    Name string
    The name of the record.
    domain String
    The domain name of the record.
    name String
    The name of the record.
    domain string
    The domain name of the record.
    name string
    The name of the record.
    domain str
    The domain name of the record.
    name str
    The name of the record.
    domain String
    The domain name of the record.
    name String
    The name of the record.

    getRecord Result

    The following output properties are available:

    Data 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.
    Domain string
    Flags int
    An unsigned integer between 0-255 used for CAA records.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    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.
    Weight int
    The weight for SRV records.
    Data 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.
    Domain string
    Flags int
    An unsigned integer between 0-255 used for CAA records.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    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.
    Weight int
    The weight for SRV records.
    data 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.
    domain String
    flags Integer
    An unsigned integer between 0-255 used for CAA records.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    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.
    weight Integer
    The weight for SRV records.
    data 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.
    domain string
    flags number
    An unsigned integer between 0-255 used for CAA records.
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    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.
    weight number
    The weight for SRV records.
    data 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.
    domain str
    flags int
    An unsigned integer between 0-255 used for CAA records.
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    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.
    weight int
    The weight for SRV records.
    data 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.
    domain String
    flags Number
    An unsigned integer between 0-255 used for CAA records.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    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.
    weight Number
    The weight for SRV records.

    Package Details

    Repository
    DigitalOcean pulumi/pulumi-digitalocean
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the digitalocean Terraform Provider.
    digitalocean logo
    DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi