digitalocean.DnsRecord
Explore with Pulumi AI
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)
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
}
// 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
})
}
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 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}
Create DnsRecord Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new DnsRecord(name: string, args: DnsRecordArgs, opts?: CustomResourceOptions);
@overload
def DnsRecord(resource_name: str,
args: DnsRecordArgs,
opts: Optional[ResourceOptions] = None)
@overload
def DnsRecord(resource_name: str,
opts: Optional[ResourceOptions] = None,
domain: Optional[str] = None,
type: Optional[Union[str, RecordType]] = None,
value: 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,
weight: Optional[int] = 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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var dnsRecordResource = new DigitalOcean.DnsRecord("dnsRecordResource", new()
{
Domain = "string",
Type = "string",
Value = "string",
Flags = 0,
Name = "string",
Port = 0,
Priority = 0,
Tag = "string",
Ttl = 0,
Weight = 0,
});
example, err := digitalocean.NewDnsRecord(ctx, "dnsRecordResource", &digitalocean.DnsRecordArgs{
Domain: pulumi.String("string"),
Type: pulumi.String("string"),
Value: pulumi.String("string"),
Flags: pulumi.Int(0),
Name: pulumi.String("string"),
Port: pulumi.Int(0),
Priority: pulumi.Int(0),
Tag: pulumi.String("string"),
Ttl: pulumi.Int(0),
Weight: pulumi.Int(0),
})
var dnsRecordResource = new DnsRecord("dnsRecordResource", DnsRecordArgs.builder()
.domain("string")
.type("string")
.value("string")
.flags(0)
.name("string")
.port(0)
.priority(0)
.tag("string")
.ttl(0)
.weight(0)
.build());
dns_record_resource = digitalocean.DnsRecord("dnsRecordResource",
domain="string",
type="string",
value="string",
flags=0,
name="string",
port=0,
priority=0,
tag="string",
ttl=0,
weight=0)
const dnsRecordResource = new digitalocean.DnsRecord("dnsRecordResource", {
domain: "string",
type: "string",
value: "string",
flags: 0,
name: "string",
port: 0,
priority: 0,
tag: "string",
ttl: 0,
weight: 0,
});
type: digitalocean:DnsRecord
properties:
domain: string
flags: 0
name: string
port: 0
priority: 0
tag: string
ttl: 0
type: string
value: string
weight: 0
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.
Digital Ocean. Record Type - The type of record. Must be one of
A
,AAAA
,CAA
,CNAME
,MX
,NS
,TXT
, orSRV
. - 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
orSRV
. Must be between 0 and 65535. - Tag string
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - 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 | Record
Type - The type of record. Must be one of
A
,AAAA
,CAA
,CNAME
,MX
,NS
,TXT
, orSRV
. - 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
orSRV
. Must be between 0 and 65535. - Tag string
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - 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 | Record
Type - The type of record. Must be one of
A
,AAAA
,CAA
,CNAME
,MX
,NS
,TXT
, orSRV
. - 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
orSRV
. Must be between 0 and 65535. - tag String
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - 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 | Record
Type - The type of record. Must be one of
A
,AAAA
,CAA
,CNAME
,MX
,NS
,TXT
, orSRV
. - 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
orSRV
. Must be between 0 and 65535. - tag string
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - 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 | Record
Type - The type of record. Must be one of
A
,AAAA
,CAA
,CNAME
,MX
,NS
,TXT
, orSRV
. - 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
orSRV
. Must be between 0 and 65535. - tag str
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - 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
, orSRV
. - 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
orSRV
. Must be between 0 and 65535. - tag String
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - 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:
Look up 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.
- 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
orSRV
. Must be between 0 and 65535. - Tag string
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - Ttl int
- The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.
- Type
string | Pulumi.
Digital Ocean. Record Type - The type of record. Must be one of
A
,AAAA
,CAA
,CNAME
,MX
,NS
,TXT
, orSRV
. - 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
orSRV
. Must be between 0 and 65535. - Tag string
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - Ttl int
- The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.
- Type
string | Record
Type - The type of record. Must be one of
A
,AAAA
,CAA
,CNAME
,MX
,NS
,TXT
, orSRV
. - 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
orSRV
. Must be between 0 and 65535. - tag String
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - ttl Integer
- The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.
- type
String | Record
Type - The type of record. Must be one of
A
,AAAA
,CAA
,CNAME
,MX
,NS
,TXT
, orSRV
. - 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
orSRV
. Must be between 0 and 65535. - tag string
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - ttl number
- The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.
- type
string | Record
Type - The type of record. Must be one of
A
,AAAA
,CAA
,CNAME
,MX
,NS
,TXT
, orSRV
. - 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
orSRV
. Must be between 0 and 65535. - tag str
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - ttl int
- The time to live for the record, in seconds. Must be at least 0. Defaults to 1800.
- type
str | Record
Type - The type of record. Must be one of
A
,AAAA
,CAA
,CNAME
,MX
,NS
,TXT
, orSRV
. - 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
orSRV
. Must be between 0 and 65535. - tag String
- The tag of the record. Only valid when type is
CAA
. Must be one ofissue
,issuewild
, oriodef
. - 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
, orSRV
. - 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, RecordTypeArgs
- A
- A
- AAAA
- AAAA
- CAA
- CAA
- CNAME
- CNAME
- MX
- MX
- NS
- NS
- TXT
- TXT
- SRV
- SRV
- Record
Type A - A
- Record
Type AAAA - AAAA
- Record
Type CAA - CAA
- Record
Type CNAME - CNAME
- Record
Type MX - MX
- Record
Type NS - NS
- Record
Type TXT - TXT
- Record
Type 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
- "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
~> 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>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- DigitalOcean pulumi/pulumi-digitalocean
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
digitalocean
Terraform Provider.