FEATURES OPEN SOURCE ABOUT DOCS LOGIN REGISTER

aws_route53_record

Provides a Route53 record resource.

Example Usage

Simple routing policy

resource "aws_route53_record" "www" {
   zone_id = "${aws_route53_zone.primary.zone_id}"
   name = "www.example.com"
   type = "A"
   ttl = "300"
   records = ["${aws_eip.lb.public_ip}"]
}

Weighted routing policy

Other routing policies are configured similarly. See AWS Route53 Developer Guide for details.

resource "aws_route53_record" "www-dev" {
  zone_id = "${aws_route53_zone.primary.zone_id}"
  name = "www"
  type = "CNAME"
  ttl = "5"
  weighted_routing_policy {
    weight = 10
  }
  set_identifier = "dev"
  records = ["dev.example.com"]
}

resource "aws_route53_record" "www-live" {
  zone_id = "${aws_route53_zone.primary.zone_id}"
  name = "www"
  type = "CNAME"
  ttl = "5"
  weighted_routing_policy {
    weight = 90
  }
  set_identifier = "live"
  records = ["live.example.com"]
}

Alias record

See related part of AWS Route53 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.

resource "aws_elb" "main" {
  name = "foobar-terraform-elb"
  availability_zones = ["us-east-1c"]

  listener {
    instance_port = 80
    instance_protocol = "http"
    lb_port = 80
    lb_protocol = "http"
  }
}

resource "aws_route53_record" "www" {
  zone_id = "${aws_route53_zone.primary.zone_id}"
  name = "example.com"
  type = "A"

  alias {
    name = "${aws_elb.main.dns_name}"
    zone_id = "${aws_elb.main.zone_id}"
    evaluate_target_health = true
  }
}

Argument Reference

The following arguments are supported:

Exactly one of records or alias must be specified: this determines whether it’s an alias record.

Alias records support the following:

Failover routing policies support the following:

Geolocation routing policies support the following:

Latency routing policies support the following:

Weighted routing policies support the following:

Attributes Reference


See the source of this document at Terraform.io