We recommend using Azure Native.
azure.dns.MxRecord
Explore with Pulumi AI
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "West Europe",
});
const exampleZone = new azure.dns.Zone("example", {
name: "mydomain.com",
resourceGroupName: example.name,
});
const exampleMxRecord = new azure.dns.MxRecord("example", {
name: "test",
zoneName: exampleZone.name,
resourceGroupName: example.name,
ttl: 300,
records: [
{
preference: "10",
exchange: "mail1.contoso.com",
},
{
preference: "20",
exchange: "mail2.contoso.com",
},
],
tags: {
Environment: "Production",
},
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="example-resources",
location="West Europe")
example_zone = azure.dns.Zone("example",
name="mydomain.com",
resource_group_name=example.name)
example_mx_record = azure.dns.MxRecord("example",
name="test",
zone_name=example_zone.name,
resource_group_name=example.name,
ttl=300,
records=[
{
"preference": "10",
"exchange": "mail1.contoso.com",
},
{
"preference": "20",
"exchange": "mail2.contoso.com",
},
],
tags={
"Environment": "Production",
})
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/dns"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-resources"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleZone, err := dns.NewZone(ctx, "example", &dns.ZoneArgs{
Name: pulumi.String("mydomain.com"),
ResourceGroupName: example.Name,
})
if err != nil {
return err
}
_, err = dns.NewMxRecord(ctx, "example", &dns.MxRecordArgs{
Name: pulumi.String("test"),
ZoneName: exampleZone.Name,
ResourceGroupName: example.Name,
Ttl: pulumi.Int(300),
Records: dns.MxRecordRecordArray{
&dns.MxRecordRecordArgs{
Preference: pulumi.String("10"),
Exchange: pulumi.String("mail1.contoso.com"),
},
&dns.MxRecordRecordArgs{
Preference: pulumi.String("20"),
Exchange: pulumi.String("mail2.contoso.com"),
},
},
Tags: pulumi.StringMap{
"Environment": pulumi.String("Production"),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-resources",
Location = "West Europe",
});
var exampleZone = new Azure.Dns.Zone("example", new()
{
Name = "mydomain.com",
ResourceGroupName = example.Name,
});
var exampleMxRecord = new Azure.Dns.MxRecord("example", new()
{
Name = "test",
ZoneName = exampleZone.Name,
ResourceGroupName = example.Name,
Ttl = 300,
Records = new[]
{
new Azure.Dns.Inputs.MxRecordRecordArgs
{
Preference = "10",
Exchange = "mail1.contoso.com",
},
new Azure.Dns.Inputs.MxRecordRecordArgs
{
Preference = "20",
Exchange = "mail2.contoso.com",
},
},
Tags =
{
{ "Environment", "Production" },
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.dns.Zone;
import com.pulumi.azure.dns.ZoneArgs;
import com.pulumi.azure.dns.MxRecord;
import com.pulumi.azure.dns.MxRecordArgs;
import com.pulumi.azure.dns.inputs.MxRecordRecordArgs;
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 example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("example-resources")
.location("West Europe")
.build());
var exampleZone = new Zone("exampleZone", ZoneArgs.builder()
.name("mydomain.com")
.resourceGroupName(example.name())
.build());
var exampleMxRecord = new MxRecord("exampleMxRecord", MxRecordArgs.builder()
.name("test")
.zoneName(exampleZone.name())
.resourceGroupName(example.name())
.ttl(300)
.records(
MxRecordRecordArgs.builder()
.preference(10)
.exchange("mail1.contoso.com")
.build(),
MxRecordRecordArgs.builder()
.preference(20)
.exchange("mail2.contoso.com")
.build())
.tags(Map.of("Environment", "Production"))
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-resources
location: West Europe
exampleZone:
type: azure:dns:Zone
name: example
properties:
name: mydomain.com
resourceGroupName: ${example.name}
exampleMxRecord:
type: azure:dns:MxRecord
name: example
properties:
name: test
zoneName: ${exampleZone.name}
resourceGroupName: ${example.name}
ttl: 300
records:
- preference: 10
exchange: mail1.contoso.com
- preference: 20
exchange: mail2.contoso.com
tags:
Environment: Production
Create MxRecord Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new MxRecord(name: string, args: MxRecordArgs, opts?: CustomResourceOptions);
@overload
def MxRecord(resource_name: str,
args: MxRecordArgs,
opts: Optional[ResourceOptions] = None)
@overload
def MxRecord(resource_name: str,
opts: Optional[ResourceOptions] = None,
records: Optional[Sequence[MxRecordRecordArgs]] = None,
resource_group_name: Optional[str] = None,
ttl: Optional[int] = None,
zone_name: Optional[str] = None,
name: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None)
func NewMxRecord(ctx *Context, name string, args MxRecordArgs, opts ...ResourceOption) (*MxRecord, error)
public MxRecord(string name, MxRecordArgs args, CustomResourceOptions? opts = null)
public MxRecord(String name, MxRecordArgs args)
public MxRecord(String name, MxRecordArgs args, CustomResourceOptions options)
type: azure:dns:MxRecord
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 MxRecordArgs
- 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 MxRecordArgs
- 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 MxRecordArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args MxRecordArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args MxRecordArgs
- 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 mxRecordResource = new Azure.Dns.MxRecord("mxRecordResource", new()
{
Records = new[]
{
new Azure.Dns.Inputs.MxRecordRecordArgs
{
Exchange = "string",
Preference = "string",
},
},
ResourceGroupName = "string",
Ttl = 0,
ZoneName = "string",
Name = "string",
Tags =
{
{ "string", "string" },
},
});
example, err := dns.NewMxRecord(ctx, "mxRecordResource", &dns.MxRecordArgs{
Records: dns.MxRecordRecordArray{
&dns.MxRecordRecordArgs{
Exchange: pulumi.String("string"),
Preference: pulumi.String("string"),
},
},
ResourceGroupName: pulumi.String("string"),
Ttl: pulumi.Int(0),
ZoneName: pulumi.String("string"),
Name: pulumi.String("string"),
Tags: pulumi.StringMap{
"string": pulumi.String("string"),
},
})
var mxRecordResource = new MxRecord("mxRecordResource", MxRecordArgs.builder()
.records(MxRecordRecordArgs.builder()
.exchange("string")
.preference("string")
.build())
.resourceGroupName("string")
.ttl(0)
.zoneName("string")
.name("string")
.tags(Map.of("string", "string"))
.build());
mx_record_resource = azure.dns.MxRecord("mxRecordResource",
records=[{
"exchange": "string",
"preference": "string",
}],
resource_group_name="string",
ttl=0,
zone_name="string",
name="string",
tags={
"string": "string",
})
const mxRecordResource = new azure.dns.MxRecord("mxRecordResource", {
records: [{
exchange: "string",
preference: "string",
}],
resourceGroupName: "string",
ttl: 0,
zoneName: "string",
name: "string",
tags: {
string: "string",
},
});
type: azure:dns:MxRecord
properties:
name: string
records:
- exchange: string
preference: string
resourceGroupName: string
tags:
string: string
ttl: 0
zoneName: string
MxRecord 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 MxRecord resource accepts the following input properties:
- Records
List<Mx
Record Record> - A list of values that make up the MX record. Each
record
block supports fields documented below. - Resource
Group stringName - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- Ttl int
- The Time To Live (TTL) of the DNS record in seconds.
- Zone
Name string - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
- Name string
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - Dictionary<string, string>
- A mapping of tags to assign to the resource.
- Records
[]Mx
Record Record Args - A list of values that make up the MX record. Each
record
block supports fields documented below. - Resource
Group stringName - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- Ttl int
- The Time To Live (TTL) of the DNS record in seconds.
- Zone
Name string - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
- Name string
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - map[string]string
- A mapping of tags to assign to the resource.
- records
List<Mx
Record Record> - A list of values that make up the MX record. Each
record
block supports fields documented below. - resource
Group StringName - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- ttl Integer
- The Time To Live (TTL) of the DNS record in seconds.
- zone
Name String - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
- name String
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - Map<String,String>
- A mapping of tags to assign to the resource.
- records
Mx
Record Record[] - A list of values that make up the MX record. Each
record
block supports fields documented below. - resource
Group stringName - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- ttl number
- The Time To Live (TTL) of the DNS record in seconds.
- zone
Name string - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
- name string
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - {[key: string]: string}
- A mapping of tags to assign to the resource.
- records
Sequence[Mx
Record Record Args] - A list of values that make up the MX record. Each
record
block supports fields documented below. - resource_
group_ strname - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- ttl int
- The Time To Live (TTL) of the DNS record in seconds.
- zone_
name str - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
- name str
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - Mapping[str, str]
- A mapping of tags to assign to the resource.
- records List<Property Map>
- A list of values that make up the MX record. Each
record
block supports fields documented below. - resource
Group StringName - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- ttl Number
- The Time To Live (TTL) of the DNS record in seconds.
- zone
Name String - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
- name String
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - Map<String>
- A mapping of tags to assign to the resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the MxRecord resource produces the following output properties:
Look up Existing MxRecord Resource
Get an existing MxRecord 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?: MxRecordState, opts?: CustomResourceOptions): MxRecord
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
fqdn: Optional[str] = None,
name: Optional[str] = None,
records: Optional[Sequence[MxRecordRecordArgs]] = None,
resource_group_name: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
ttl: Optional[int] = None,
zone_name: Optional[str] = None) -> MxRecord
func GetMxRecord(ctx *Context, name string, id IDInput, state *MxRecordState, opts ...ResourceOption) (*MxRecord, error)
public static MxRecord Get(string name, Input<string> id, MxRecordState? state, CustomResourceOptions? opts = null)
public static MxRecord get(String name, Output<String> id, MxRecordState 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.
- Fqdn string
- The FQDN of the DNS MX Record.
- Name string
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - Records
List<Mx
Record Record> - A list of values that make up the MX record. Each
record
block supports fields documented below. - Resource
Group stringName - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- Dictionary<string, string>
- A mapping of tags to assign to the resource.
- Ttl int
- The Time To Live (TTL) of the DNS record in seconds.
- Zone
Name string - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
- Fqdn string
- The FQDN of the DNS MX Record.
- Name string
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - Records
[]Mx
Record Record Args - A list of values that make up the MX record. Each
record
block supports fields documented below. - Resource
Group stringName - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- map[string]string
- A mapping of tags to assign to the resource.
- Ttl int
- The Time To Live (TTL) of the DNS record in seconds.
- Zone
Name string - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
- fqdn String
- The FQDN of the DNS MX Record.
- name String
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - records
List<Mx
Record Record> - A list of values that make up the MX record. Each
record
block supports fields documented below. - resource
Group StringName - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- Map<String,String>
- A mapping of tags to assign to the resource.
- ttl Integer
- The Time To Live (TTL) of the DNS record in seconds.
- zone
Name String - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
- fqdn string
- The FQDN of the DNS MX Record.
- name string
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - records
Mx
Record Record[] - A list of values that make up the MX record. Each
record
block supports fields documented below. - resource
Group stringName - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- {[key: string]: string}
- A mapping of tags to assign to the resource.
- ttl number
- The Time To Live (TTL) of the DNS record in seconds.
- zone
Name string - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
- fqdn str
- The FQDN of the DNS MX Record.
- name str
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - records
Sequence[Mx
Record Record Args] - A list of values that make up the MX record. Each
record
block supports fields documented below. - resource_
group_ strname - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- Mapping[str, str]
- A mapping of tags to assign to the resource.
- ttl int
- The Time To Live (TTL) of the DNS record in seconds.
- zone_
name str - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
- fqdn String
- The FQDN of the DNS MX Record.
- name String
- The name of the DNS MX Record. Defaults to
@
(root). Changing this forces a new resource to be created. - records List<Property Map>
- A list of values that make up the MX record. Each
record
block supports fields documented below. - resource
Group StringName - Specifies the resource group where the DNS Zone (parent resource) exists. Changing this forces a new resource to be created.
- Map<String>
- A mapping of tags to assign to the resource.
- ttl Number
- The Time To Live (TTL) of the DNS record in seconds.
- zone
Name String - Specifies the DNS Zone where the resource exists. Changing this forces a new resource to be created.
Supporting Types
MxRecordRecord, MxRecordRecordArgs
- Exchange string
- The mail server responsible for the domain covered by the MX record.
- Preference string
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
- Exchange string
- The mail server responsible for the domain covered by the MX record.
- Preference string
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
- exchange String
- The mail server responsible for the domain covered by the MX record.
- preference String
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
- exchange string
- The mail server responsible for the domain covered by the MX record.
- preference string
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
- exchange str
- The mail server responsible for the domain covered by the MX record.
- preference str
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
- exchange String
- The mail server responsible for the domain covered by the MX record.
- preference String
- String representing the "preference” value of the MX records. Records with lower preference value take priority.
Import
MX records can be imported using the resource id
, e.g.
$ pulumi import azure:dns/mxRecord:MxRecord example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/dnsZones/zone1/MX/myrecord1
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurerm
Terraform Provider.