terraform-aws-modules/terraform-aws-route53

Route53 Record module does not support weighted_records

hawkesn opened this issue · 2 comments

Currently the route53 record module doesn't support weighted_records.

Using a dynamic block would solve one part of the problem:

  dynamic "weighted_routing_policy" {
    for_each = length(keys(lookup(each.value, "weighted_routing_policy", {}))) == 0 ? [] : [true]

    content {
      weight = each.value.weighted_routing_policy.weight
    }
  }

Unfortunately, the locals calculated would produce non-unique keys as the name and type would be identical. Re-writing the for loop would produce unique keys:

recordsets = { for idx, rs in var.records : "${rs.name} ${idx}" => rs }

I tested it this way works well without editing the for loop

dynamic "weighted_routing_policy" {
    for_each = length(keys(lookup(each.value, "weighted_routing_policy", {}))) == 0 ? [] : [true]

    content {
      weight                 = lookup(each.value.weighted_routing_policy,"weight", true)
    }
  }

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.