Search code examples
amazon-web-servicesaws-sdkaws-cliamazon-elb

Filtering with aws cli


I have a load-balancer running in AWS, which has a listener with a number of rules based on host header parameters.

Is it possible to use --query or --filters to filter out the RuleArn based on the host header?

So aws elbv2 describe-rules --listener-arn arn:aws:elasticloadbalancing:eu-west-2:1234567890:listener/net/1234567890/1234567890/1234567890 --query 'Rules[].RuleArn' --output text gives me all the RuleArns but I would like to add in an extra condition to only spit out the RuleArn based on the value of the host header I provide.


Solution

  • ❯❯ aws elbv2 describe-rules --listener-arn \
    arn:aws:elasticloadbalancing:us-east-1:1234567890:listener/app/mytesting/86b9380a1a34/5ef713678269 \
    --query 'Rules[?Actions[0].RedirectConfig.Host == `example.com`].RuleArn' \
    --output text
    
    arn:aws:elasticloadbalancing:us-east-1:1234567890:listener-rule/app/mytesting/86b9380a3a0c1a34/5ef7136ad78269/f04455bc36298f