Skip to content

Instantly share code, notes, and snippets.

@tfentonz
Last active June 13, 2023 10:44
Show Gist options
  • Select an option

  • Save tfentonz/96d39dc021b382c3d58eb2f96f4605df to your computer and use it in GitHub Desktop.

Select an option

Save tfentonz/96d39dc021b382c3d58eb2f96f4605df to your computer and use it in GitHub Desktop.
AWS CLI command to list ELB listener rule priorities

Get load balancer ARN

arn=$(aws elbv2 describe-load-balancers --names <value> --query 'LoadBalancers[].[LoadBalancerArn]' --output text)

Get listeners

aws elbv2 describe-listeners --load-balancer-arn "$arn" --query 'Listeners[].{ListenerArn:ListenerArn,Protocol:Protocol,Port:Port}'

[
    {
        "ListenerArn": "<listener_arn>",
        "Protocol": "HTTPS",
        "Port": 443
    },
    {
        "ListenerArn": "<listener_arn>",
        "Protocol": "HTTP",
        "Port": 80
    }
]

Describe rules

aws elbv2 describe-rules --listener-arn "<listener_arn>" --query 'Rules[].{Priority:Priority,Host:Conditions[0].Values[0]}'

[
    {
        "Priority": "1",
        "Host": "www.foo.com"
    },
    {
        "Priority": "2",
        "Host": "www.bar.com"
    },
    {
        "Priority": "5",
        "Host": "www.foobar.com"
    },
    {
        "Priority": "default",
        "Host": null
    }
]
@xx745

xx745 commented Sep 15, 2022

Copy link
Copy Markdown

Old but good, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment