Record Args
Provides a Route53 record resource.
Example Usage
Simple routing policy
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
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 Record("www", RecordArgs.builder()
.zoneId(aws_route53_zone.primary().zone_id())
.name("www.example.com")
.type("A")
.ttl(300)
.records(aws_eip.lb().public_ip())
.build());
}
}
Weighted routing policy
Other routing policies are configured similarly. See Amazon Route 53 Developer Guide for details.
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
import com.pulumi.aws.route53.inputs.RecordWeightedRoutingPolicyArgs;
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_dev = new Record("www-dev", RecordArgs.builder()
.zoneId(aws_route53_zone.primary().zone_id())
.name("www")
.type("CNAME")
.ttl(5)
.weightedRoutingPolicies(RecordWeightedRoutingPolicyArgs.builder()
.weight(10)
.build())
.setIdentifier("dev")
.records("dev.example.com")
.build());
var www_live = new Record("www-live", RecordArgs.builder()
.zoneId(aws_route53_zone.primary().zone_id())
.name("www")
.type("CNAME")
.ttl(5)
.weightedRoutingPolicies(RecordWeightedRoutingPolicyArgs.builder()
.weight(90)
.build())
.setIdentifier("live")
.records("live.example.com")
.build());
}
}
Alias record
See related part of Amazon Route 53 Developer Guide to understand differences between alias and non-alias records. TTL for all alias records is 60 seconds, you cannot change this, therefore ttl
has to be omitted in alias records.
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elb.LoadBalancer;
import com.pulumi.aws.elb.LoadBalancerArgs;
import com.pulumi.aws.elb.inputs.LoadBalancerListenerArgs;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
import com.pulumi.aws.route53.inputs.RecordAliasArgs;
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 main = new LoadBalancer("main", LoadBalancerArgs.builder()
.availabilityZones("us-east-1c")
.listeners(LoadBalancerListenerArgs.builder()
.instancePort(80)
.instanceProtocol("http")
.lbPort(80)
.lbProtocol("http")
.build())
.build());
var www = new Record("www", RecordArgs.builder()
.zoneId(aws_route53_zone.primary().zone_id())
.name("example.com")
.type("A")
.aliases(RecordAliasArgs.builder()
.name(main.dnsName())
.zoneId(main.zoneId())
.evaluateTargetHealth(true)
.build())
.build());
}
}
NS and SOA Record Management
When creating Route 53 zones, the NS
and SOA
records for the zone are automatically created. Enabling the allow_overwrite
argument will allow managing these records in a single deployment without the requirement for import
.
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.route53.Zone;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
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 exampleZone = new Zone("exampleZone");
var exampleRecord = new Record("exampleRecord", RecordArgs.builder()
.allowOverwrite(true)
.name("test.example.com")
.ttl(172800)
.type("NS")
.zoneId(exampleZone.zoneId())
.records(
exampleZone.nameServers().applyValue(nameServers -> nameServers[0]),
exampleZone.nameServers().applyValue(nameServers -> nameServers[1]),
exampleZone.nameServers().applyValue(nameServers -> nameServers[2]),
exampleZone.nameServers().applyValue(nameServers -> nameServers[3]))
.build());
}
}
Import
Route53 Records can be imported using ID of the record, which is the zone identifier, record name, and record type, separated by underscores (_
)E.g.,
$ pulumi import aws:route53/record:Record myrecord Z4KAPRWWNC7JR_dev.example.com_NS
If the record also contains a set identifier, it should be appended
$ pulumi import aws:route53/record:Record myrecord Z4KAPRWWNC7JR_dev.example.com_NS_dev
Constructors
Properties
An alias block. Conflicts with ttl
&records
. Documented below.
Allow creation of this record to overwrite an existing record, if any. This does not affect the ability to update the record using this provider and does not prevent other resources within this provider or manual Route 53 changes outside this provider from overwriting this record. false
by default. This configuration is not recommended for most environments. Exactly one of records
or alias
must be specified: this determines whether it's an alias record.
A block indicating a routing policy based on the IP network ranges of requestors. Conflicts with any other routing policy. Documented below.
A block indicating the routing behavior when associated health check fails. Conflicts with any other routing policy. Documented below.
A block indicating a routing policy based on the geolocation of the requestor. Conflicts with any other routing policy. Documented below.
The health check the record should be associated with.
A block indicating a routing policy based on the latency between the requestor and an AWS region. Conflicts with any other routing policy. Documented below.
Set to true
to indicate a multivalue answer routing policy. Conflicts with any other routing policy.
Unique identifier to differentiate records with routing policies from one another. Required if using cidr_routing_policy
, failover_routing_policy
, geolocation_routing_policy
, latency_routing_policy
, multivalue_answer_routing_policy
, or weighted_routing_policy
.
The record type. Valid values are A
, AAAA
, CAA
, CNAME
, DS
, MX
, NAPTR
, NS
, PTR
, SOA
, SPF
, SRV
and TXT
.
A block indicating a weighted routing policy. Conflicts with any other routing policy. Documented below.