Skip to content

terraform destroy specific instance with index value deleting all DNS record sets #1

@rayuduc

Description

@rayuduc

Hello,
Thanks for the google compute module, this is really cool stuff!!
Here am struck with some issue, when we create VM's with dns_record_name as hostname its able to create all host names with respective internal ip address, but when we destroy single instance from count of x, its deleting all DNS records,
Is there anyway if destroy single instance and should delete respective DNS record instead delete all instances DNS record sets?

terraform destroy -target="module.testing-vm.google_compute_instance.instances[1]"

resource "google_dns_record_set" "dns_record" {
  count = var.amount
  name = "${google_compute_instance.node.*.name[count.index]}.${var.dns_zone}"
  #name = "${format("%s%02d", var.dns_record_name, count.index + 1)}.${var.dns_zone}"
  #name = "${var.name}.${var.dns_zone}"
  #name = "${google_compute_instance.node.*.name[count.index]}.${var.dns_zone}"
  managed_zone = "${var.dns_name}"
  type = "A"
  ttl  = 300
  #rrdatas = ["${google_compute_instance.node.*.network_interface.0.network_ip}"]
  rrdatas = ["${google_compute_instance.node.*.network_interface.0.network_ip[count.index]}"] 

Thanks in advance!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions