Reverse DNS records failing

433 views
Skip to first unread message

Bubunia Patra

unread,
Mar 21, 2018, 3:50:07 AM3/21/18
to Terraform
Hi all,

I am trying to create the PTR (Reverse Route53 DNS Records) using Terraform and Terraform v0.9.11. Any idea how I can fix this issue?

variable "vpc_cidr_block" {
    default = "10.149.0.0/16"
}

variable "ENVIRONMENT" {
    default = "test"
}

variable "NAME" {
    default = "Internal"
}


resource "aws_vpc" "new_vpc" {
  cidr_block = "${var.vpc_cidr_block}"
}

output "vpc_cidr_block" {
  value = "${aws_vpc.new_vpc.cidr_block}"
}

resource "aws_route53_zone" "test-r53-internal-reverse" {
        vpc_id = "${aws_vpc.new_vpc.id}"
        comment = "Test RDNS"
        name = "${format("%s.%s.in-addr.arpa.",
                 element( split(".", aws_vpc.new_vpc.cidr_block) ,1),
                 element( split(".", aws_vpc.new_vpc.cidr_block) ,0),
               )
             }"
        tags {
                Name = "${format("%s-%s-r53-internal-reverse",var.NAME,var.ENVIRONMENT)}"
                Environment = "${var.ENVIRONMENT}"
        }

}


variable "instance-count" {
   default = "4"
}

resource "aws_route53_record" "test-reverse-private" {

 name = "${format(
    "%s.%s.%s.%s.in-addr.arpa.",
      element( split(".", element(aws_instance.instance.*.private_ip, count.index)) ,3),
      element( split(".", element(aws_instance.instance.*.private_ip, count.index)) ,2),
      element( split(".", element(aws_instance.instance.*.private_ip, count.index)) ,1),
      element( split(".", element(aws_instance.instance.*.private_ip, count.index)) ,0),
    )
  }"
  type    = "PTR"
  ttl     = "600"
  records = ["${element(aws_instance.instance.*.private_ip, count.index)}"]
}


Error
=========
aws_route53_record.reverse-private: Creating...
  fqdn:               "" => "<computed>"
  name:               "" => "25.0.20.10.in-addr.arpa"
  records.#:          "" => "1"
  records.2587496556: "" => "10.20.0.25"
  ttl:                "" => "600"
  type:               "" => "PTR"
  zone_id:            "" => "Z34HSJQJ796C55"
Error applying plan:

1 error(s) occurred:

* aws_route53_record.reverse-private: 1 error(s) occurred:

* aws_route53_record.reverse-private: [ERR]: Error building changeset: InvalidChangeBatch: FATAL problem: DomainLabelEmpty (Domain label is empty) encountered with '25.0.20.10.in-addr.arpa..149.10.in-addr.arpa'
        status code: 400, request id: 8f6c44af-2cda-11e8-a4a6-dd22ba64537c

Bubunia Patra

unread,
Mar 21, 2018, 4:17:16 AM3/21/18
to Terraform
Reply all
Reply to author
Forward
0 new messages