1. Packages
  2. Netlify Provider
  3. API Docs
  4. DnsRecord
netlify 0.2.2 published on Friday, Mar 7, 2025 by netlify

netlify.DnsRecord

Explore with Pulumi AI

Netlify DNS record. Read more

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as netlify from "@pulumi/netlify";

const www = new netlify.DnsRecord("www", {
    type: "A",
    zoneId: netlify_dns_zone.example.id,
    hostname: "www.example.com",
    value: "198.18.0.50",
});
const calendar = new netlify.DnsRecord("calendar", {
    type: "CNAME",
    zoneId: netlify_dns_zone.example.id,
    hostname: "calendar.example.com",
    value: "ghs.googlehosted.com.",
});
const mx = new netlify.DnsRecord("mx", {
    type: "MX",
    zoneId: netlify_dns_zone.example.id,
    hostname: "example.com",
    value: "smtp.google.com",
    priority: 1,
});
Copy
import pulumi
import pulumi_netlify as netlify

www = netlify.DnsRecord("www",
    type="A",
    zone_id=netlify_dns_zone["example"]["id"],
    hostname="www.example.com",
    value="198.18.0.50")
calendar = netlify.DnsRecord("calendar",
    type="CNAME",
    zone_id=netlify_dns_zone["example"]["id"],
    hostname="calendar.example.com",
    value="ghs.googlehosted.com.")
mx = netlify.DnsRecord("mx",
    type="MX",
    zone_id=netlify_dns_zone["example"]["id"],
    hostname="example.com",
    value="smtp.google.com",
    priority=1)
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/netlify/netlify"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := netlify.NewDnsRecord(ctx, "www", &netlify.DnsRecordArgs{
			Type:     pulumi.String("A"),
			ZoneId:   pulumi.Any(netlify_dns_zone.Example.Id),
			Hostname: pulumi.String("www.example.com"),
			Value:    pulumi.String("198.18.0.50"),
		})
		if err != nil {
			return err
		}
		_, err = netlify.NewDnsRecord(ctx, "calendar", &netlify.DnsRecordArgs{
			Type:     pulumi.String("CNAME"),
			ZoneId:   pulumi.Any(netlify_dns_zone.Example.Id),
			Hostname: pulumi.String("calendar.example.com"),
			Value:    pulumi.String("ghs.googlehosted.com."),
		})
		if err != nil {
			return err
		}
		_, err = netlify.NewDnsRecord(ctx, "mx", &netlify.DnsRecordArgs{
			Type:     pulumi.String("MX"),
			ZoneId:   pulumi.Any(netlify_dns_zone.Example.Id),
			Hostname: pulumi.String("example.com"),
			Value:    pulumi.String("smtp.google.com"),
			Priority: pulumi.Float64(1),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Netlify = Pulumi.Netlify;

return await Deployment.RunAsync(() => 
{
    var www = new Netlify.DnsRecord("www", new()
    {
        Type = "A",
        ZoneId = netlify_dns_zone.Example.Id,
        Hostname = "www.example.com",
        Value = "198.18.0.50",
    });

    var calendar = new Netlify.DnsRecord("calendar", new()
    {
        Type = "CNAME",
        ZoneId = netlify_dns_zone.Example.Id,
        Hostname = "calendar.example.com",
        Value = "ghs.googlehosted.com.",
    });

    var mx = new Netlify.DnsRecord("mx", new()
    {
        Type = "MX",
        ZoneId = netlify_dns_zone.Example.Id,
        Hostname = "example.com",
        Value = "smtp.google.com",
        Priority = 1,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.netlify.DnsRecord;
import com.pulumi.netlify.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 www = new DnsRecord("www", DnsRecordArgs.builder()
            .type("A")
            .zoneId(netlify_dns_zone.example().id())
            .hostname("www.example.com")
            .value("198.18.0.50")
            .build());

        var calendar = new DnsRecord("calendar", DnsRecordArgs.builder()
            .type("CNAME")
            .zoneId(netlify_dns_zone.example().id())
            .hostname("calendar.example.com")
            .value("ghs.googlehosted.com.")
            .build());

        var mx = new DnsRecord("mx", DnsRecordArgs.builder()
            .type("MX")
            .zoneId(netlify_dns_zone.example().id())
            .hostname("example.com")
            .value("smtp.google.com")
            .priority(1)
            .build());

    }
}
Copy
resources:
  www:
    type: netlify:DnsRecord
    properties:
      type: A
      zoneId: ${netlify_dns_zone.example.id}
      hostname: www.example.com
      value: 198.18.0.50
  calendar:
    type: netlify:DnsRecord
    properties:
      type: CNAME
      zoneId: ${netlify_dns_zone.example.id}
      hostname: calendar.example.com
      value: ghs.googlehosted.com.
  mx:
    type: netlify:DnsRecord
    properties:
      type: MX
      zoneId: ${netlify_dns_zone.example.id}
      hostname: example.com
      value: smtp.google.com
      priority: 1
Copy

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,
              hostname: Optional[str] = None,
              type: Optional[str] = None,
              value: Optional[str] = None,
              zone_id: Optional[str] = None,
              flag: Optional[float] = None,
              priority: Optional[float] = None,
              tag: Optional[str] = None,
              ttl: Optional[float] = 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: netlify:DnsRecord
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. DnsRecordArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. 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 This property is required. string
The unique name of the resource.
args This property is required. DnsRecordArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. DnsRecordArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. 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 Netlify.DnsRecord("dnsRecordResource", new()
{
    Hostname = "string",
    Type = "string",
    Value = "string",
    ZoneId = "string",
    Flag = 0,
    Priority = 0,
    Tag = "string",
    Ttl = 0,
});
Copy
example, err := netlify.NewDnsRecord(ctx, "dnsRecordResource", &netlify.DnsRecordArgs{
Hostname: pulumi.String("string"),
Type: pulumi.String("string"),
Value: pulumi.String("string"),
ZoneId: pulumi.String("string"),
Flag: pulumi.Float64(0),
Priority: pulumi.Float64(0),
Tag: pulumi.String("string"),
Ttl: pulumi.Float64(0),
})
Copy
var dnsRecordResource = new DnsRecord("dnsRecordResource", DnsRecordArgs.builder()
    .hostname("string")
    .type("string")
    .value("string")
    .zoneId("string")
    .flag(0)
    .priority(0)
    .tag("string")
    .ttl(0)
    .build());
Copy
dns_record_resource = netlify.DnsRecord("dnsRecordResource",
    hostname="string",
    type="string",
    value="string",
    zone_id="string",
    flag=0,
    priority=0,
    tag="string",
    ttl=0)
Copy
const dnsRecordResource = new netlify.DnsRecord("dnsRecordResource", {
    hostname: "string",
    type: "string",
    value: "string",
    zoneId: "string",
    flag: 0,
    priority: 0,
    tag: "string",
    ttl: 0,
});
Copy
type: netlify:DnsRecord
properties:
    flag: 0
    hostname: string
    priority: 0
    tag: string
    ttl: 0
    type: string
    value: string
    zoneId: string
Copy

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

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The DnsRecord resource accepts the following input properties:

Hostname This property is required. string
The hostname for the DNS record. For example, www.example.com.
Type This property is required. string
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
Value This property is required. string
ZoneId This property is required. string
Flag double
Priority double
Tag string
Ttl double
Hostname This property is required. string
The hostname for the DNS record. For example, www.example.com.
Type This property is required. string
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
Value This property is required. string
ZoneId This property is required. string
Flag float64
Priority float64
Tag string
Ttl float64
hostname This property is required. String
The hostname for the DNS record. For example, www.example.com.
type This property is required. String
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
value This property is required. String
zoneId This property is required. String
flag Double
priority Double
tag String
ttl Double
hostname This property is required. string
The hostname for the DNS record. For example, www.example.com.
type This property is required. string
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
value This property is required. string
zoneId This property is required. string
flag number
priority number
tag string
ttl number
hostname This property is required. str
The hostname for the DNS record. For example, www.example.com.
type This property is required. str
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
value This property is required. str
zone_id This property is required. str
flag float
priority float
tag str
ttl float
hostname This property is required. String
The hostname for the DNS record. For example, www.example.com.
type This property is required. String
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
value This property is required. String
zoneId This property is required. String
flag Number
priority Number
tag String
ttl Number

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
LastUpdated string
Id string
The provider-assigned unique ID for this managed resource.
LastUpdated string
id String
The provider-assigned unique ID for this managed resource.
lastUpdated String
id string
The provider-assigned unique ID for this managed resource.
lastUpdated string
id str
The provider-assigned unique ID for this managed resource.
last_updated str
id String
The provider-assigned unique ID for this managed resource.
lastUpdated String

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,
        flag: Optional[float] = None,
        hostname: Optional[str] = None,
        last_updated: Optional[str] = None,
        priority: Optional[float] = None,
        tag: Optional[str] = None,
        ttl: Optional[float] = None,
        type: Optional[str] = None,
        value: Optional[str] = None,
        zone_id: Optional[str] = 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)
resources:  _:    type: netlify:DnsRecord    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
Flag double
Hostname string
The hostname for the DNS record. For example, www.example.com.
LastUpdated string
Priority double
Tag string
Ttl double
Type string
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
Value string
ZoneId string
Flag float64
Hostname string
The hostname for the DNS record. For example, www.example.com.
LastUpdated string
Priority float64
Tag string
Ttl float64
Type string
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
Value string
ZoneId string
flag Double
hostname String
The hostname for the DNS record. For example, www.example.com.
lastUpdated String
priority Double
tag String
ttl Double
type String
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
value String
zoneId String
flag number
hostname string
The hostname for the DNS record. For example, www.example.com.
lastUpdated string
priority number
tag string
ttl number
type string
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
value string
zoneId string
flag float
hostname str
The hostname for the DNS record. For example, www.example.com.
last_updated str
priority float
tag str
ttl float
type str
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
value str
zone_id str
flag Number
hostname String
The hostname for the DNS record. For example, www.example.com.
lastUpdated String
priority Number
tag String
ttl Number
type String
One of A, AAAA, ALIAS, CAA, CNAME, MX, NS, SPF, or TXT
value String
zoneId String

Import

Import a DNS record by its zone ID and its record ID

$ pulumi import netlify:index/dnsRecord:DnsRecord www_example 6600abcdef1234567890abcd:6600abcdef1234567890abcd
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
netlify netlify/terraform-provider-netlify
License
Notes
This Pulumi package is based on the netlify Terraform Provider.