Until now, the following scenarios looks like always problematic, even if I check/compare new ALB rule number with existing ALB rule number it doesn't matter:
1) Replacing hostname in ALB rule with the new hostname but with existing priority number. Error (I have two hostnames with different priority numbers):
Error applying plan:2 error(s) occurred:
*aws_lb_listener_rule.ALB_RULE_NAME: 1 error(s) occurred:* aws_lb_listener_rule.ALB_RULE_NAME: Error creating LB Listener Rule: PriorityInUse: Priority '40' is currently in use
*aws_lb_listener_rule.ALB_RULE_NAME2: 1 error(s) occurred:* aws_lb_listener_rule.ALB_RULE_NAME2: Error creating LB Listener Rule: PriorityInUse: Priority '41' is currently in use
2) Removing ALB rules and leaving only one active fails with the following error:
Error applying plan:1 error(s) occurred:
* aws_lb_listener_rule.ALB_RULE_NAME3: 1 error(s) occurred:
* aws_lb_listener_rule.ALB_RULE_NAME4: Error creating LB Listener Rule: PriorityInUse: Priority '50' is currently in use
On the next Terraform apply, the issues goes away.
I think this is a bug in Terraform as looks like other people were reporting it (like
here or
here) and stating that the core problem is that for some reason TF state files are not being updated properly with most recent info; there are some potential workarounds with using random names in ALB TargetGroup name or similar, but essentially it is a bug.
Or maybe anyone had the same issues and solved them somehow differently?
Thanks again.