As mentioned in the title, I'd like to change the default rule of a listener for an ALB using AWS CLI. In particular, I want to change which Target Group is used. The desired result should be switching the target ARN inside the action field. This is possible using the AWS console quite easily by editing the action field. Console allows this by removing the default value (the one set at the time of creation), but AWS CLI does not, for some reason. What I've tried is using the following command:
aws elbv2 modify-rule --actions Type=forward,ForwardConfig={TargetGroups={TargetGroupArn=$TARGET_GROUP_ARN}}
--rule-arn $RULE_ARN
Which returns the following:
An error occurred (OperationNotPermitted) when calling the ModifyRule operation: Default rule '$RULE_ARN' cannot be modified
Does anyone have any idea what I'm doing wrong? The describe command returns a JSON that contains the information that's proportional to the one I'm trying to modify.
I've managed to find the solution. The rule needs to be modified by editing the listener in question, instead of the default rule itself. The command is the following one:
The documentation didn't help much, but the
aws elbv2 modify-rule help
command did help. I somehow missed it on my first reading. It says the following:To modify the actions for the default rule, use ModifyListener
.