Problem removing resources

Hello I set up this little function to not have to replicate code on my module, when I add everything runs smoothly, but when I remove it from this error, will it be a bug?

locals {
  lb-tg-register = flatten([
    for arn in aws_lb_target_group.new-target.*.arn : [
      for lb-tg_dest_instances in var.lb-targetgroup[index(aws_lb_target_group.new-target.*.arn, arn)].lb-tg_dest_instances : {
        arn             = arn
        instance        = element(split(":", lb-tg_dest_instances,),0)
        port            = element(split(":", lb-tg_dest_instances,),1)
      }
    ]
  ])
}

resource "aws_lb_target_group_attachment" "register-machine" {
    count = length(local.lb-tg-register)
    target_group_arn  = local.lb-tg-register[count.index].arn
    target_id         = local.lb-tg-register[count.index].instance
    port              = local.lb-tg-register[count.index].port
}


Error: Invalid index

  on vpc-projects/06-targetgroups.tf line 37, in locals:
  37:       for lb-tg_dest_instances in var.lb-targetgroup[index(aws_lb_target_group.new-target.*.arn, arn)].lb-tg_dest_instances : {
    |----------------
    | aws_lb_target_group.new-target is tuple with 2 elements
    | var.lb-targetgroup is list of object with 1 element

The given key does not identify an element in this collection value.