Error creating LB Listener Rule: PriorityInUse: Priority '61' is currently in use

2,186 views
Skip to first unread message

Igor David

unread,
Apr 17, 2019, 12:29:34 PM4/17/19
to Terraform
Hello,

Did anyone had the problem when changing AWS ALB rule names, with the priority number which was already in use?

 We have ALB rule with priority "61" and we want to rename "host-header" filed to something else (e.g. to www.hostname2.com), but leave same priority number "61":


resource "aws_lb_listener_rule" "listener_rule1" {
depends_on = ["aws_lb_target_group.target_group_name1"]
listener_arn = "${aws_lb_listener.listener1.arn}"
priority = "61"

action {
type = "forward"
target_group_arn = "${aws_lb_target_group.target_group_name1.id}"
}

condition {
field = "host-header"
values = ["www.hostname.com"]
}

condition {
field = "path-pattern"
values = ["/STATIC"]

}

lifecycle {
create_before_destroy = true
}
}

When we run Terraform plan/apply, it throws error:

"Error creating LB Listener Rule: PriorityInUse: Priority
'61' is currently in use"

However after subsequent Terraform plan/apply run, it is able to create ALB rule 61.

Anyone had the same and solved the problem somehow?

Thanks in advance.

Arnvid Lau Karstad

unread,
Apr 17, 2019, 1:14:14 PM4/17/19
to terrafo...@googlegroups.com
try to set create-before-destroy = false..
but those can be a bit of hassle.

br Arnvid

--
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/c2144bd6-0fc4-4406-b763-671f0e00c3dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

laxman Singh Rathore

unread,
Apr 18, 2019, 1:33:00 AM4/18/19
to terrafo...@googlegroups.com
Do simple one thing, use count +1 so defined priority automatically increased +1  after every execution. Or one minor hack use Aws cli to get existing priority and do +1.  Export this value as terraform variable. I have verified secind hack a month back for my use case.  

Regards 
Laxman singh 
Lead DevOps team. 


laxman Singh Rathore

unread,
Apr 24, 2019, 1:48:39 AM4/24/19
to terrafo...@googlegroups.com
Hi Igor, 

Have you checked mention solution for your usecase ?

Regards 
Laxman singh 

Igor David

unread,
Apr 30, 2019, 6:28:07 AM4/30/19
to terrafo...@googlegroups.com
Hello,

Thanks for all the answers.

I tried  “create-before-destroy = false“ but it doesn't work.

I am currently evaluating option with recording current values with Boto3 and then creating new ALB rules based on that, however it would be probably best to have this logic already built in Terraform.

Thanks again.

Kind regards,
Igor


You received this message because you are subscribed to a topic in the Google Groups "Terraform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/terraform-tool/E2X9pr1iYLs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/CACDNCvZZdGshp%3DdpjzBa1B3XmobVRTw0ymdjH8ovoV4TcLjpqw%40mail.gmail.com.

Igor David

unread,
May 20, 2019, 6:04:07 PM5/20/19
to terrafo...@googlegroups.com
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.

Igor David

unread,
May 24, 2019, 11:06:37 AM5/24/19
to terrafo...@googlegroups.com
Turned out that this last issue I was having is actually happening because of the way I was provisioning new ALB Rules.

As we use templates to provision TF resources, it was giving new ALB rules also new names, so TF was trying to create new ALB rule with the same priority as the old one, which naturally was failing.

After changing the scripts to actually keep TF resource names the same and just change ALB name or priority, it works fine.

Thanks again for your help.

Kind regards,
Igor

laxman Singh Rathore

unread,
May 26, 2019, 9:13:44 AM5/26/19
to terrafo...@googlegroups.com
Hi, 

Can you please share snip you implement for priority implement. 

As I said earlier seem you implement same.  I have  used the Aws cli with terraform module earlier to make priority +1 with current priority.  So module is not complent about priority.

Regards.
Laxman singh 

Reply all
Reply to author
Forward
0 new messages