DnsRecord

class DnsRecord : KotlinCustomResource

Provides a DigitalOcean DNS record resource.

Example Usage

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: digitalocean.RecordType.A,
name: "www",
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: digitalocean.RecordType.MX,
name: "@",
priority: 10,
value: "mail.example.com.",
});
export const wwwFqdn = www.fqdn;
export const 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=digitalocean.RecordType.A,
name="www",
value="192.168.0.11")
# Add a MX record for the example.com domain itself.
mx = digitalocean.DnsRecord("mx",
domain=default.id,
type=digitalocean.RecordType.MX,
name="@",
priority=10,
value="mail.example.com.")
pulumi.export("wwwFqdn", www.fqdn)
pulumi.export("mxFqdn", mx.fqdn)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;
return await Deployment.RunAsync(() =>
{
var @default = new DigitalOcean.Domain("default", new()
{
Name = "example.com",
});
// Add an A record to the domain for www.example.com.
var www = new DigitalOcean.DnsRecord("www", new()
{
Domain = @default.Id,
Type = DigitalOcean.RecordType.A,
Name = "www",
Value = "192.168.0.11",
});
// Add a MX record for the example.com domain itself.
var mx = new DigitalOcean.DnsRecord("mx", new()
{
Domain = @default.Id,
Type = DigitalOcean.RecordType.MX,
Name = "@",
Priority = 10,
Value = "mail.example.com.",
});
return new Dictionary<string, object?>
{
["wwwFqdn"] = www.Fqdn,
["mxFqdn"] = mx.Fqdn,
};
});
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 {
_default, err := digitalocean.NewDomain(ctx, "default", &digitalocean.DomainArgs{
Name: pulumi.String("example.com"),
})
if err != nil {
return err
}
// Add an A record to the domain for www.example.com.
www, err := digitalocean.NewDnsRecord(ctx, "www", &digitalocean.DnsRecordArgs{
Domain: _default.ID(),
Type: pulumi.String(digitalocean.RecordTypeA),
Name: pulumi.String("www"),
Value: pulumi.String("192.168.0.11"),
})
if err != nil {
return err
}
// Add a MX record for the example.com domain itself.
mx, err := digitalocean.NewDnsRecord(ctx, "mx", &digitalocean.DnsRecordArgs{
Domain: _default.ID(),
Type: pulumi.String(digitalocean.RecordTypeMX),
Name: pulumi.String("@"),
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 com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.Domain;
import com.pulumi.digitalocean.DomainArgs;
import com.pulumi.digitalocean.DnsRecord;
import com.pulumi.digitalocean.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) {
var default_ = new Domain("default", DomainArgs.builder()
.name("example.com")
.build());
// Add an A record to the domain for www.example.com.
var www = new DnsRecord("www", DnsRecordArgs.builder()
.domain(default_.id())
.type("A")
.name("www")
.value("192.168.0.11")
.build());
// Add a MX record for the example.com domain itself.
var mx = new DnsRecord("mx", DnsRecordArgs.builder()
.domain(default_.id())
.type("MX")
.name("@")
.priority(10)
.value("mail.example.com.")
.build());
ctx.export("wwwFqdn", www.fqdn());
ctx.export("mxFqdn", mx.fqdn());
}
}
resources:
default:
type: digitalocean:Domain
properties:
name: example.com
# Add an A record to the domain for www.example.com.
www:
type: digitalocean:DnsRecord
properties:
domain: ${default.id}
type: A
name: www
value: 192.168.0.11
# Add a MX record for the example.com domain itself.
mx:
type: digitalocean:DnsRecord
properties:
domain: ${default.id}
type: MX
name: '@'
priority: 10
value: mail.example.com.
outputs:
# Output the FQDN for the www A record.
wwwFqdn: ${www.fqdn}
# Output the FQDN for the MX record.
mxFqdn: ${mx.fqdn}

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

~> You find the id of the records using the DigitalOcean API or CLI. Run the follow command to list the IDs for all DNS records on a domain: doctl compute domain records list <domain.name>

Properties

Link copied to clipboard
val domain: Output<String>

The domain to add the record to.

Link copied to clipboard
val flags: Output<Int>?

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

Link copied to clipboard
val fqdn: Output<String>

The FQDN of the record

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val name: Output<String>

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

Link copied to clipboard
val port: Output<Int>?

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

Link copied to clipboard
val priority: Output<Int>?

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

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val tag: Output<String>?

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

Link copied to clipboard
val ttl: Output<Int>

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

Link copied to clipboard
val type: Output<String>

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

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val value: Output<String>

The value of the record.

Link copied to clipboard
val weight: Output<Int>?

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