Skip to content

ALB (AWS Application Load Balancer): Temp disable rule

0

For debugging purposes, our web dev has asked me to temporarily disable one of the rules on our ALB. But at least in the web interface (AWS console), there seems to be no option to mark a rule as disabled without deleting the rule and somehow remembering (outside AWS) what rule to retype after the test without the rule.

For example, if the load balancer "arn:aws:elasticloadbalancing:rainforest-north-1:012345678901:loadbalancer/app/lb123/123456789abcdef0" has a rule named "something-clever-3", which takes paths of the form "/foo/bar/baz" and responds in a certain way, the need is to temporarily not apply that rule while testing a web site change. (The real names/numbers are obviously different from "123 in the Amazon forest").

Is there some non-obvious method (such as a CloudShell CLI command) to disable an ALB rule or save the rules to some readable file format that can be readily re-imported to the existing ALB without recreating the ALB as a new object (there are other AWS settings referring to the specific ALB by its ID)?

1 Answer
1
Accepted Answer

There is no direct "disable" option for Application Load Balancer rules in AWS. However, you have a few options to temporarily disable a rule without deleting it:

  1. Modify the rule priority: You can use the AWS CLI to set the rule to a very high priority number (lower precedence) so it won't be matched before other rules. You can use the set-rule-priority command for this.

  2. Modify the rule's condition: You can temporarily change the path pattern to something that won't match any actual traffic (like "/never-match-this-path-123456/*") using the modify-rule command:

aws elbv2 modify-rule \
--actions Type=forward,TargetGroupArn=[your-target-group-arn] \
--conditions Field=path-pattern,Values='/never-match-this-path-123456/*' \
--rule-arn [your-rule-arn]

When you're done testing, you can modify the rule again to restore the original path pattern ("/foo/bar/baz").

This approach allows you to effectively disable the rule without deleting it, preserving all its configuration for easy restoration later. The AWS CLI provides this flexibility that isn't available in the console interface.
Sources
Elastic Load Balancing - Version 2 examples using AWS CLI - AWS SDK Code Examples
Use ModifyRule with a CLI - AWS SDK Code Examples

answered a year ago

EXPERT

reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.