Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Edit a listener rule for your Application Load Balancer
You can edit the action and conditions for a listener rule at any time. Rule updates
do not take effect immediately, so requests could be routed using the previous rule
configuration for a short time after you update a rule. Any in-flight requests are
completed.
Modify the default action
The default action is assigned to a rule named Default. You
can keep the current rule type and change the required information, or you can
change the rule type and provide the new required information.
- Console
-
To modify the default action
Open the Amazon EC2 console at
https://console.amazonaws.cn/ec2/.
-
On the navigation pane, choose Load
Balancers.
-
Select the load balancer.
-
On the Listeners and rules tab, select
the text in the Protocol:Port column to
open the detail page for the listener.
-
On the Rules tab, in the
Listener rules section, select the
checkbox for the default rule. Choose
Actions, then Edit
rule.
-
Under Default action, update the
authentication action and routing action as needed.
- Amazon CLI
-
To modify the default action
Use the modify-listener command. The following example updates
the target group for the forward
action.
aws elbv2 modify-listener \
--listener-arn listener-arn
\
--default-actions Type=forward,TargetGroupArn=new-target-group-arn
- CloudFormation
-
To modify the default action
Update the AWS::ElasticLoadBalancingV2::Listener resource.
Resources:
myHTTPlistener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
Properties:
LoadBalancerArn: !Ref myLoadBalancer
Protocol: HTTP
Port: 80
DefaultActions:
- Type: "forward"
TargetGroupArn: !Ref myNewTargetGroup
Update rule priorities
Rules are evaluated in priority order, from the lowest value to the highest value.
The default rule is evaluated last. You can change the priority of a nondefault rule
at any time. You can't change the priority of the default rule.
- Console
-
To update rule priorities
Open the Amazon EC2 console at
https://console.amazonaws.cn/ec2/.
-
In the navigation pane, choose Load
Balancers.
-
Select the load balancer.
-
On the Listeners and rules tab, select
the text in the Protocol:Port column to
open the detail page for the listener.
-
On the Rules tab, select the listener
rule and then choose Actions,
Reprioritize rules.
-
In the Listener rules section, the
Priority column displays the current
rule priorities. To update a rule priority, enter a value from
1-50,000.
-
Choose Save changes.
- Amazon CLI
-
To update rule priorities
Use the set-rule-priorities command.
aws elbv2 set-rule-priorities \
--rule-priorities "RuleArn=listener-rule-arn
,Priority=5
"
- CloudFormation
-
To update rule priorities
Update the AWS::ElasticLoadBalancingV2::ListenerRule
resource.
Resources:
myListenerRule:
Type: 'AWS::ElasticLoadBalancingV2::ListenerRule'
Properties:
ListenerArn: !Ref myListener
Priority: 5
Conditions:
- Field: host-header
Values:
- example.com
- www.example.com
Actions:
- Type: forward
TargetGroupArn: !Ref myTargetGroup
Update actions and conditions
You can update the actions and conditions for a rule.
- Console
-
To update rule actions and conditions
Open the Amazon EC2 console at
https://console.amazonaws.cn/ec2/.
-
In the navigation pane, choose Load
Balancers.
-
Select the load balancer.
-
On the Listeners and rules tab, select
the text in the Protocol:Port column to
open the detail page for the listener.
-
On the Rules tab, select the listener
rule and then choose Actions,
Edit rule.
-
Update the rule actions and conditions as needed. For detailed steps,
see Add a rule.
-
Choose Next.
-
(Optional) Update the priority.
-
Choose Next.
-
Choose Save changes.
- Amazon CLI
-
To update rule actions and conditions
Use the modify-rule command with the --actions
option, the --conditions
option, or both options.
For examples of these options, see Add a rule.
- CloudFormation
-
To update rule actions and conditions
Update the AWS::ElasticLoadBalancingV2::ListenerRule
resource.
For example rules, see Add a rule.
Tags help you to categorize your listeners and rules in different ways. For
example, you can tag a resource by purpose, owner, or environment. Tag keys must be
unique for each rule. If you add a tag with a key that is already associated with
the rule, it updates the value of that tag.
When you are finished with a tag, you can remove it.
- Console
-
To manage the tags for a rule
Open the Amazon EC2 console at
https://console.amazonaws.cn/ec2/.
-
In the navigation pane, choose Load
Balancers.
-
Choose the name of the load balancer to open its details
page.
-
On the Listeners and rules tab, select
the text in the Protocol:Port column to
open the detail page for the listener.
-
On the Rules tab, select the text in the
Name tag column to open the detail page
for the rule.
-
On the rule details page, choose Manage
tags.
-
On the Manage tags page, do one or more
of the following:
-
To add a tag, choose Add new tag
and enter values for Key and
Value.
-
To delete a tag, choose Remove
next to the tag.
-
To update a tag, enter new values for
Key or
Value.
-
Choose Save changes.
- Amazon CLI
-
To add tags to a rule
Use the add-tags command.
aws elbv2 add-tags \
--resource-arns listener-rule-arn
\
--tags "Key=project
,Value=lima
" "Key=department
,Value=digital-media
"
To remove tags from a rule
Use the remove-tags command.
aws elbv2 remove-tags \
--resource-arns listener-rule-arn
\
--tag-keys project
department
- CloudFormation
-
To add tags to a rule
Update the AWS::ElasticLoadBalancingV2::ListenerRule
resource.
Resources:
myListenerRule:
Type: 'AWS::ElasticLoadBalancingV2::ListenerRule'
Properties:
ListenerArn: !Ref myListener
Priority: 10
Conditions:
- Field: host-header
Values:
- example.com
- www.example.com
Actions:
- Type: forward
TargetGroupArn: !Ref myTargetGroup
Tags:
- Key: 'project
'
Value: 'lima
'
- Key: 'department
'
Value: 'digital-media
'