How to update aws_route53_record?

818 views
Skip to first unread message

Danny Rehelis

unread,
Jun 9, 2017, 5:44:58 AM6/9/17
to terrafo...@googlegroups.com
Is it possible to update A record to CNAME?

resource "aws_route53_record" "dns_record_vip" {
    zone_id = "<id>"
    name = "aaa.myzone.com"
    type = "A"
    ttl = "300"
    records = ["1.1.1.1"]
}
...
...
...
resource "aws_route53_record" "dns_record_prim" {
    depends_on = ["aws_route53_record.dns_record_vip"]
    zone_id = "<id>"
    name = "aaa.myzone.com"
    type = "CNAME"
    ttl = "30"
    health_check_id = "e2e..."
    failover_routing_policy = {
        type = "PRIMARY"
    }
   set_identifier = "app1-Primary"
   records = ["app1.myzone.com"]
}

Resualt with -

1 error(s) occurred:

* aws_route53_record.dns_record_prim: 1 error(s) occurred:

* aws_route53_record.dns_record_prim: [ERR]: Error building changeset: InvalidChangeBatch: RRSet of type CNAME with DNS name aaa.myzone.com. is not permitted as it conflicts with other records with the same DNS name in zone myzone.com.
status code: 400, request id: 9cc...

Brian Lalor

unread,
Jun 9, 2017, 5:58:38 AM6/9/17
to terrafo...@googlegroups.com
I don’t believe it’s possible to have both A and CNAME records with the same name in a zone.  That’s what you’re attempting to do here.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/CAObRFCW6Dm5pju7uMswF2OeAro5OCcH9Tv%2BHvTU%2BbM%3Dh6gpugA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

— 
Brian Lalor

signature.asc

Danny Rehelis

unread,
Jun 9, 2017, 8:28:14 AM6/9/17
to terrafo...@googlegroups.com
How would you suggest to update the record?
I need to set A record at first and later update it to CNAME with failover_routing_policy.

David Maze

unread,
Jun 9, 2017, 8:50:07 AM6/9/17
to Terraform
On Friday, June 9, 2017 at 5:44:58 AM UTC-4, Danny Rehelis wrote:
Is it possible to update...

As a general statement, "no".  When you declare a resource, you're telling Terraform, when it's done, that a resource should exist with that value.
 
resource "aws_route53_record" "dns_record_vip" {
    zone_id = "<id>"
    name = "aaa.myzone.com"
    type = "A"
    ttl = "300"
    records = ["1.1.1.1"]
}

"Terraform, when you finish, this DNS A record must exist."  The existence of another declaration for the same DNS name ("before" and "after" don't really matter to Terraform, depends_on is just an ordering constraint) doesn't imply "change" or "the previous one is wrong", it's trying to tell Terraform "apples are both red and green" and it doesn't understand how to do it.

(This is different from these declarations being "commands", like, well, pretty much every other system; if I used something like the equivalent Ansible route53 module I could make the change as you're describing, but Ansible couldn't automatically destroy the DNS record when I was done with the project, double-check that the DNS record existed before running the project, or reorder execution to ensure the DNS record existed before anything else used it.)
Reply all
Reply to author
Forward
0 new messages