We recommend using Azure Native.
azure.dns.CNameRecord
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 exampleCNameRecord = new azure.dns.CNameRecord("example", {
name: "test",
zoneName: exampleZone.name,
resourceGroupName: example.name,
ttl: 300,
record: "contoso.com",
});
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_c_name_record = azure.dns.CNameRecord("example",
name="test",
zone_name=example_zone.name,
resource_group_name=example.name,
ttl=300,
record="contoso.com")
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.NewCNameRecord(ctx, "example", &dns.CNameRecordArgs{
Name: pulumi.String("test"),
ZoneName: exampleZone.Name,
ResourceGroupName: example.Name,
Ttl: pulumi.Int(300),
Record: pulumi.String("contoso.com"),
})
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 exampleCNameRecord = new Azure.Dns.CNameRecord("example", new()
{
Name = "test",
ZoneName = exampleZone.Name,
ResourceGroupName = example.Name,
Ttl = 300,
Record = "contoso.com",
});
});
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.CNameRecord;
import com.pulumi.azure.dns.CNameRecordArgs;
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 exampleCNameRecord = new CNameRecord("exampleCNameRecord", CNameRecordArgs.builder()
.name("test")
.zoneName(exampleZone.name())
.resourceGroupName(example.name())
.ttl(300)
.record("contoso.com")
.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}
exampleCNameRecord:
type: azure:dns:CNameRecord
name: example
properties:
name: test
zoneName: ${exampleZone.name}
resourceGroupName: ${example.name}
ttl: 300
record: contoso.com
Alias Record)
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 target = new azure.dns.CNameRecord("target", {
name: "target",
zoneName: exampleZone.name,
resourceGroupName: example.name,
ttl: 300,
record: "contoso.com",
});
const exampleCNameRecord = new azure.dns.CNameRecord("example", {
name: "test",
zoneName: exampleZone.name,
resourceGroupName: example.name,
ttl: 300,
targetResourceId: target.id,
});
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)
target = azure.dns.CNameRecord("target",
name="target",
zone_name=example_zone.name,
resource_group_name=example.name,
ttl=300,
record="contoso.com")
example_c_name_record = azure.dns.CNameRecord("example",
name="test",
zone_name=example_zone.name,
resource_group_name=example.name,
ttl=300,
target_resource_id=target.id)
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
}
target, err := dns.NewCNameRecord(ctx, "target", &dns.CNameRecordArgs{
Name: pulumi.String("target"),
ZoneName: exampleZone.Name,
ResourceGroupName: example.Name,
Ttl: pulumi.Int(300),
Record: pulumi.String("contoso.com"),
})
if err != nil {
return err
}
_, err = dns.NewCNameRecord(ctx, "example", &dns.CNameRecordArgs{
Name: pulumi.String("test"),
ZoneName: exampleZone.Name,
ResourceGroupName: example.Name,
Ttl: pulumi.Int(300),
TargetResourceId: target.ID(),
})
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 target = new Azure.Dns.CNameRecord("target", new()
{
Name = "target",
ZoneName = exampleZone.Name,
ResourceGroupName = example.Name,
Ttl = 300,
Record = "contoso.com",
});
var exampleCNameRecord = new Azure.Dns.CNameRecord("example", new()
{
Name = "test",
ZoneName = exampleZone.Name,
ResourceGroupName = example.Name,
Ttl = 300,
TargetResourceId = target.Id,
});
});
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.CNameRecord;
import com.pulumi.azure.dns.CNameRecordArgs;
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 target = new CNameRecord("target", CNameRecordArgs.builder()
.name("target")
.zoneName(exampleZone.name())
.resourceGroupName(example.name())
.ttl(300)
.record("contoso.com")
.build());
var exampleCNameRecord = new CNameRecord("exampleCNameRecord", CNameRecordArgs.builder()
.name("test")
.zoneName(exampleZone.name())
.resourceGroupName(example.name())
.ttl(300)
.targetResourceId(target.id())
.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}
target:
type: azure:dns:CNameRecord
properties:
name: target
zoneName: ${exampleZone.name}
resourceGroupName: ${example.name}
ttl: 300
record: contoso.com
exampleCNameRecord:
type: azure:dns:CNameRecord
name: example
properties:
name: test
zoneName: ${exampleZone.name}
resourceGroupName: ${example.name}
ttl: 300
targetResourceId: ${target.id}
Create CNameRecord Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new CNameRecord(name: string, args: CNameRecordArgs, opts?: CustomResourceOptions);
@overload
def CNameRecord(resource_name: str,
args: CNameRecordArgs,
opts: Optional[ResourceOptions] = None)
@overload
def CNameRecord(resource_name: str,
opts: Optional[ResourceOptions] = None,
resource_group_name: Optional[str] = None,
ttl: Optional[int] = None,
zone_name: Optional[str] = None,
name: Optional[str] = None,
record: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
target_resource_id: Optional[str] = None)
func NewCNameRecord(ctx *Context, name string, args CNameRecordArgs, opts ...ResourceOption) (*CNameRecord, error)
public CNameRecord(string name, CNameRecordArgs args, CustomResourceOptions? opts = null)
public CNameRecord(String name, CNameRecordArgs args)
public CNameRecord(String name, CNameRecordArgs args, CustomResourceOptions options)
type: azure:dns:CNameRecord
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 CNameRecordArgs
- 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 CNameRecordArgs
- 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 CNameRecordArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args CNameRecordArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args CNameRecordArgs
- 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 cnameRecordResource = new Azure.Dns.CNameRecord("cnameRecordResource", new()
{
ResourceGroupName = "string",
Ttl = 0,
ZoneName = "string",
Name = "string",
Record = "string",
Tags =
{
{ "string", "string" },
},
TargetResourceId = "string",
});
example, err := dns.NewCNameRecord(ctx, "cnameRecordResource", &dns.CNameRecordArgs{
ResourceGroupName: pulumi.String("string"),
Ttl: pulumi.Int(0),
ZoneName: pulumi.String("string"),
Name: pulumi.String("string"),
Record: pulumi.String("string"),
Tags: pulumi.StringMap{
"string": pulumi.String("string"),
},
TargetResourceId: pulumi.String("string"),
})
var cnameRecordResource = new CNameRecord("cnameRecordResource", CNameRecordArgs.builder()
.resourceGroupName("string")
.ttl(0)
.zoneName("string")
.name("string")
.record("string")
.tags(Map.of("string", "string"))
.targetResourceId("string")
.build());
cname_record_resource = azure.dns.CNameRecord("cnameRecordResource",
resource_group_name="string",
ttl=0,
zone_name="string",
name="string",
record="string",
tags={
"string": "string",
},
target_resource_id="string")
const cnameRecordResource = new azure.dns.CNameRecord("cnameRecordResource", {
resourceGroupName: "string",
ttl: 0,
zoneName: "string",
name: "string",
record: "string",
tags: {
string: "string",
},
targetResourceId: "string",
});
type: azure:dns:CNameRecord
properties:
name: string
record: string
resourceGroupName: string
tags:
string: string
targetResourceId: string
ttl: 0
zoneName: string
CNameRecord 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 CNameRecord resource accepts the following input properties:
- 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 CNAME Record. Changing this forces a new resource to be created.
- Record string
- The target of the CNAME.
- Dictionary<string, string>
A mapping of tags to assign to the resource.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- Target
Resource stringId - The Azure resource id of the target object. Conflicts with
record
.
- 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 CNAME Record. Changing this forces a new resource to be created.
- Record string
- The target of the CNAME.
- map[string]string
A mapping of tags to assign to the resource.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- Target
Resource stringId - The Azure resource id of the target object. Conflicts with
record
.
- 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 CNAME Record. Changing this forces a new resource to be created.
- record String
- The target of the CNAME.
- Map<String,String>
A mapping of tags to assign to the resource.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- target
Resource StringId - The Azure resource id of the target object. Conflicts with
record
.
- 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 CNAME Record. Changing this forces a new resource to be created.
- record string
- The target of the CNAME.
- {[key: string]: string}
A mapping of tags to assign to the resource.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- target
Resource stringId - The Azure resource id of the target object. Conflicts with
record
.
- 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 CNAME Record. Changing this forces a new resource to be created.
- record str
- The target of the CNAME.
- Mapping[str, str]
A mapping of tags to assign to the resource.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- target_
resource_ strid - The Azure resource id of the target object. Conflicts with
record
.
- 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 CNAME Record. Changing this forces a new resource to be created.
- record String
- The target of the CNAME.
- Map<String>
A mapping of tags to assign to the resource.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- target
Resource StringId - The Azure resource id of the target object. Conflicts with
record
.
Outputs
All input properties are implicitly available as output properties. Additionally, the CNameRecord resource produces the following output properties:
Look up Existing CNameRecord Resource
Get an existing CNameRecord 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?: CNameRecordState, opts?: CustomResourceOptions): CNameRecord
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
fqdn: Optional[str] = None,
name: Optional[str] = None,
record: Optional[str] = None,
resource_group_name: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
target_resource_id: Optional[str] = None,
ttl: Optional[int] = None,
zone_name: Optional[str] = None) -> CNameRecord
func GetCNameRecord(ctx *Context, name string, id IDInput, state *CNameRecordState, opts ...ResourceOption) (*CNameRecord, error)
public static CNameRecord Get(string name, Input<string> id, CNameRecordState? state, CustomResourceOptions? opts = null)
public static CNameRecord get(String name, Output<String> id, CNameRecordState 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 CName Record.
- Name string
- The name of the DNS CNAME Record. Changing this forces a new resource to be created.
- Record string
- The target of the CNAME.
- 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.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- Target
Resource stringId - The Azure resource id of the target object. Conflicts with
record
. - 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 CName Record.
- Name string
- The name of the DNS CNAME Record. Changing this forces a new resource to be created.
- Record string
- The target of the CNAME.
- 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.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- Target
Resource stringId - The Azure resource id of the target object. Conflicts with
record
. - 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 CName Record.
- name String
- The name of the DNS CNAME Record. Changing this forces a new resource to be created.
- record String
- The target of the CNAME.
- 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.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- target
Resource StringId - The Azure resource id of the target object. Conflicts with
record
. - 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 CName Record.
- name string
- The name of the DNS CNAME Record. Changing this forces a new resource to be created.
- record string
- The target of the CNAME.
- 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.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- target
Resource stringId - The Azure resource id of the target object. Conflicts with
record
. - 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 CName Record.
- name str
- The name of the DNS CNAME Record. Changing this forces a new resource to be created.
- record str
- The target of the CNAME.
- 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.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- target_
resource_ strid - The Azure resource id of the target object. Conflicts with
record
. - 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 CName Record.
- name String
- The name of the DNS CNAME Record. Changing this forces a new resource to be created.
- record String
- The target of the CNAME.
- 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.
Note: either
record
ORtarget_resource_id
must be specified, but not both.- target
Resource StringId - The Azure resource id of the target object. Conflicts with
record
. - 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.
Import
CNAME records can be imported using the resource id
, e.g.
$ pulumi import azure:dns/cNameRecord:CNameRecord example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/dnsZones/zone1/CNAME/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.