DigitalOcean

Pulumi Official
Package maintained by Pulumi
v4.14.0 published on Friday, Jun 17, 2022 by Pulumi

DnsRecord

Provides a DigitalOcean DNS record resource.

Example Usage

using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

class MyStack : Stack
{
    public MyStack()
    {
        var @default = new DigitalOcean.Domain("default", new DigitalOcean.DomainArgs
        {
            Name = "example.com",
        });
        // Add an A record to the domain for www.example.com.
        var www = new DigitalOcean.DnsRecord("www", new DigitalOcean.DnsRecordArgs
        {
            Domain = @default.Id,
            Type = "A",
            Value = "192.168.0.11",
        });
        // Add a MX record for the example.com domain itself.
        var mx = new DigitalOcean.DnsRecord("mx", new DigitalOcean.DnsRecordArgs
        {
            Domain = @default.Id,
            Type = "MX",
            Priority = 10,
            Value = "mail.example.com.",
        });
        this.WwwFqdn = www.Fqdn;
        this.MxFqdn = mx.Fqdn;
    }

    [Output("wwwFqdn")]
    public Output<string> WwwFqdn { get; set; }
    [Output("mxFqdn")]
    public Output<string> MxFqdn { get; set; }
}
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.NewDomain(ctx, "default", &digitalocean.DomainArgs{
			Name: pulumi.String("example.com"),
		})
		if err != nil {
			return err
		}
		www, err := digitalocean.NewDnsRecord(ctx, "www", &digitalocean.DnsRecordArgs{
			Domain: _default.ID(),
			Type:   pulumi.String("A"),
			Value:  pulumi.String("192.168.0.11"),
		})
		if err != nil {
			return err
		}
		mx, err := digitalocean.NewDnsRecord(ctx, "mx", &digitalocean.DnsRecordArgs{
			Domain:   _default.ID(),
			Type:     pulumi.String("MX"),
			Priority: pulumi.Int(10),
			Value:    pulumi.String("mail.example.com."),
		})
		if err != nil {
			return err
		}
		ctx.Export("wwwFqdn", www.Fqdn)
		ctx.Export("mxFqdn", mx.Fqdn)
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var default_ = new Domain("default", DomainArgs.builder()        
            .name("example.com")
            .build());

        var www = new DnsRecord("www", DnsRecordArgs.builder()        
            .domain(default_.id())
            .type("A")
            .value("192.168.0.11")
            .build());

        var mx = new DnsRecord("mx", DnsRecordArgs.builder()        
            .domain(default_.id())
            .type("MX")
            .priority(10)
            .value("mail.example.com.")
            .build());

        ctx.export("wwwFqdn", www.fqdn());
        ctx.export("mxFqdn", mx.fqdn());
    }
}
import pulumi
import pulumi_digitalocean as digitalocean

default = digitalocean.Domain("default", name="example.com")
# Add an A record to the domain for www.example.com.
www = digitalocean.DnsRecord("www",
    domain=default.id,
    type="A",
    value="192.168.0.11")
# Add a MX record for the example.com domain itself.
mx = digitalocean.DnsRecord("mx",
    domain=default.id,
    type="MX",
    priority=10,
    value="mail.example.com.")
pulumi.export("wwwFqdn", www.fqdn)
pulumi.export("mxFqdn", mx.fqdn)
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const _default = new digitalocean.Domain("default", {name: "example.com"});
// Add an A record to the domain for www.example.com.
const www = new digitalocean.DnsRecord("www", {
    domain: _default.id,
    type: "A",
    value: "192.168.0.11",
});
// Add a MX record for the example.com domain itself.
const mx = new digitalocean.DnsRecord("mx", {
    domain: _default.id,
    type: "MX",
    priority: 10,
    value: "mail.example.com.",
});
export const wwwFqdn = www.fqdn;
export const mxFqdn = mx.fqdn;
resources:
  default:
    type: digitalocean:Domain
    properties:
      name: example.com
  www:
    type: digitalocean:DnsRecord
    properties:
      domain: ${default.id}
      type: A
      value: 192.168.0.11
  mx:
    type: digitalocean:DnsRecord
    properties:
      domain: ${default.id}
      type: MX
      priority: 10
      value: mail.example.com.
outputs:
  wwwFqdn: ${www.fqdn}
  mxFqdn: ${mx.fqdn}

Create a DnsRecord Resource

new DnsRecord(name: string, args: DnsRecordArgs, opts?: CustomResourceOptions);
@overload
def DnsRecord(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              domain: Optional[str] = None,
              flags: Optional[int] = None,
              name: Optional[str] = None,
              port: Optional[int] = None,
              priority: Optional[int] = None,
              tag: Optional[str] = None,
              ttl: Optional[int] = None,
              type: Optional[Union[str, RecordType]] = None,
              value: Optional[str] = None,
              weight: Optional[int] = None)
@overload
def DnsRecord(resource_name: str,
              args: DnsRecordArgs,
              opts: Optional[ResourceOptions] = None)
func NewDnsRecord(ctx *Context, name string, args DnsRecordArgs, opts ...ResourceOption) (*DnsRecord, error)
public DnsRecord(string name, DnsRecordArgs args, CustomResourceOptions? opts = null)
public DnsRecord(String name, DnsRecordArgs args)
public DnsRecord(String name, DnsRecordArgs args, CustomResourceOptions options)
type: digitalocean:DnsRecord
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args DnsRecordArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args DnsRecordArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args DnsRecordArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args DnsRecordArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args DnsRecordArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

DnsRecord Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The DnsRecord resource accepts the following input properties:

Domain string

The domain to add the record to.

Type string | Pulumi.DigitalOcean.RecordType

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

Value string

The value of the record.

Flags int

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

Name string

The hostname of the record. Use @ for records on domain's name itself.

Port int

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

Priority int

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

Tag string

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

Ttl int

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

Weight int

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

Domain string

The domain to add the record to.

Type string | RecordType

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

Value string

The value of the record.

Flags int

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

Name string

The hostname of the record. Use @ for records on domain's name itself.

Port int

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

Priority int

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

Tag string

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

Ttl int

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

Weight int

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

domain String

The domain to add the record to.

type String | RecordType

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

value String

The value of the record.

flags Integer

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

name String

The hostname of the record. Use @ for records on domain's name itself.

port Integer

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

priority Integer

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

tag String

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

ttl Integer

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

weight Integer

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

domain string

The domain to add the record to.

type string | RecordType

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

value string

The value of the record.

flags number

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

name string

The hostname of the record. Use @ for records on domain's name itself.

port number

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

priority number

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

tag string

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

ttl number

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

weight number

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

domain str

The domain to add the record to.

type str | RecordType

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

value str

The value of the record.

flags int

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

name str

The hostname of the record. Use @ for records on domain's name itself.

port int

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

priority int

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

tag str

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

ttl int

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

weight int

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

domain String

The domain to add the record to.

type String | "A" | "AAAA" | "CAA" | "CNAME" | "MX" | "NS" | "TXT" | "SRV"

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

value String

The value of the record.

flags Number

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

name String

The hostname of the record. Use @ for records on domain's name itself.

port Number

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

priority Number

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

tag String

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

ttl Number

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

weight Number

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

Outputs

All input properties are implicitly available as output properties. Additionally, the DnsRecord resource produces the following output properties:

Fqdn string

The FQDN of the record

Id string

The provider-assigned unique ID for this managed resource.

Fqdn string

The FQDN of the record

Id string

The provider-assigned unique ID for this managed resource.

fqdn String

The FQDN of the record

id String

The provider-assigned unique ID for this managed resource.

fqdn string

The FQDN of the record

id string

The provider-assigned unique ID for this managed resource.

fqdn str

The FQDN of the record

id str

The provider-assigned unique ID for this managed resource.

fqdn String

The FQDN of the record

id String

The provider-assigned unique ID for this managed resource.

Look up an Existing DnsRecord Resource

Get an existing DnsRecord resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: DnsRecordState, opts?: CustomResourceOptions): DnsRecord
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        domain: Optional[str] = None,
        flags: Optional[int] = None,
        fqdn: Optional[str] = None,
        name: Optional[str] = None,
        port: Optional[int] = None,
        priority: Optional[int] = None,
        tag: Optional[str] = None,
        ttl: Optional[int] = None,
        type: Optional[Union[str, RecordType]] = None,
        value: Optional[str] = None,
        weight: Optional[int] = None) -> DnsRecord
func GetDnsRecord(ctx *Context, name string, id IDInput, state *DnsRecordState, opts ...ResourceOption) (*DnsRecord, error)
public static DnsRecord Get(string name, Input<string> id, DnsRecordState? state, CustomResourceOptions? opts = null)
public static DnsRecord get(String name, Output<String> id, DnsRecordState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Domain string

The domain to add the record to.

Flags int

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

Fqdn string

The FQDN of the record

Name string

The hostname of the record. Use @ for records on domain's name itself.

Port int

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

Priority int

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

Tag string

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

Ttl int

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

Type string | Pulumi.DigitalOcean.RecordType

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

Value string

The value of the record.

Weight int

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

Domain string

The domain to add the record to.

Flags int

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

Fqdn string

The FQDN of the record

Name string

The hostname of the record. Use @ for records on domain's name itself.

Port int

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

Priority int

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

Tag string

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

Ttl int

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

Type string | RecordType

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

Value string

The value of the record.

Weight int

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

domain String

The domain to add the record to.

flags Integer

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

fqdn String

The FQDN of the record

name String

The hostname of the record. Use @ for records on domain's name itself.

port Integer

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

priority Integer

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

tag String

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

ttl Integer

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

type String | RecordType

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

value String

The value of the record.

weight Integer

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

domain string

The domain to add the record to.

flags number

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

fqdn string

The FQDN of the record

name string

The hostname of the record. Use @ for records on domain's name itself.

port number

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

priority number

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

tag string

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

ttl number

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

type string | RecordType

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

value string

The value of the record.

weight number

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

domain str

The domain to add the record to.

flags int

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

fqdn str

The FQDN of the record

name str

The hostname of the record. Use @ for records on domain's name itself.

port int

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

priority int

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

tag str

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

ttl int

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

type str | RecordType

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

value str

The value of the record.

weight int

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

domain String

The domain to add the record to.

flags Number

The flags of the record. Only valid when type is CAA. Must be between 0 and 255.

fqdn String

The FQDN of the record

name String

The hostname of the record. Use @ for records on domain's name itself.

port Number

The port of the record. Only valid when type is SRV. Must be between 1 and 65535.

priority Number

The priority of the record. Only valid when type is MX or SRV. Must be between 0 and 65535.

tag String

The tag of the record. Only valid when type is CAA. Must be one of issue, issuewild, or iodef.

ttl Number

The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.

type String | "A" | "AAAA" | "CAA" | "CNAME" | "MX" | "NS" | "TXT" | "SRV"

The type of record. Must be one of A, AAAA, CAA, CNAME, MX, NS, TXT, or SRV.

value String

The value of the record.

weight Number

The weight of the record. Only valid when type is SRV. Must be between 0 and 65535.

Supporting Types

RecordType

A
A
AAAA
AAAA
CAA
CAA
CNAME
CNAME
MX
MX
NS
NS
TXT
TXT
SRV
SRV
RecordTypeA
A
RecordTypeAAAA
AAAA
RecordTypeCAA
CAA
RecordTypeCNAME
CNAME
RecordTypeMX
MX
RecordTypeNS
NS
RecordTypeTXT
TXT
RecordTypeSRV
SRV
A
A
AAAA
AAAA
CAA
CAA
CNAME
CNAME
MX
MX
NS
NS
TXT
TXT
SRV
SRV
A
A
AAAA
AAAA
CAA
CAA
CNAME
CNAME
MX
MX
NS
NS
TXT
TXT
SRV
SRV
A
A
AAAA
AAAA
CAA
CAA
CNAME
CNAME
MX
MX
NS
NS
TXT
TXT
SRV
SRV
"A"
A
"AAAA"
AAAA
"CAA"
CAA
"CNAME"
CNAME
"MX"
MX
"NS"
NS
"TXT"
TXT
"SRV"
SRV

Import

Records can be imported using the domain name and record id when joined with a comma. See the following example

 $ pulumi import digitalocean:index/dnsRecord:DnsRecord example_record example.com,12345678

Package Details

Repository
https://github.com/pulumi/pulumi-digitalocean
License
Apache-2.0
Notes

This Pulumi package is based on the digitalocean Terraform Provider.