AWS-CLI - Find ELB by Name tag

You're trying to use --query to perform the role of --filter and unfortunately describe-tags does not support the --filter option.

The --query option allows you to select what fields are returned in the response. When available --filter allows you select which resources you want returned. It's described in more detail here

You can use jq to perform the function of the filter. I highly recommend it because AWS does not implement the --filter option for all CLI commands.

For your example try something like:

aws elb describe-tags --load-balancer-names some-load-balancer \
| jq -r '.TagDescriptions[] |select (.Tags[].Value=="my-desired-name-value")'

A bit more complex is to filter on the Tag Key and Value:

aws elb describe-tags --load-balancer-names some-load-balancer \
| jq -r '.TagDescriptions[] | . as $i \
| (select ($i.Tags[].Value=="my-desired-name-value")) and (select ($i.Tags[].Key=="Name")) \
| $i'

Output

{
  "LoadBalancerName": "some-load-balancer",
  "Tags": [
    {
      "Key": "Type",
      "Value": "classic"
    },
    {
      "Key": "Name",
      "Value": "my-desired-name-value"
    }
  ]
}

References

  • JQ Docs