Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hirobert/f8e677d6160250e5d953712938812cb6 to your computer and use it in GitHub Desktop.
Save hirobert/f8e677d6160250e5d953712938812cb6 to your computer and use it in GitHub Desktop.
aws load balancer (elb/alb) target group - target currently in use by a listener or a rule

This is likely happening because there are still rules associated with the load balancer that are using the target group. Unfortunately there is currently on way in the AWS console to view or edit the rules. Here is another approach:

  1. Install AWS cli: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
  2. If you have different profiles, add --profile=name_of_profile on each of the following commands
  3. aws elbv2 describe-load-balancer, get the load balancer arn
  4. aws elbv2 describe-listeners --load-balancer-arn arn:aws:elasticloadbalancing:this_is_the_load_balancer_arn, get listener arn for the listener which you associated with the target group
  5. aws elbv2 describe-rules --listener-arn arn:aws:elasticloadbalancing:this_is_the_listener_arn, get the rule arn which should contain the name of the target group you are looking to remove
  6. aws elbv2 delete-rule --rule-arn arn:aws:elasticloadbalancing:this_is_the_rule_arn

You should now be able to return to the AWS console and successfully delete the target group as it is no longer associated with the load balancer.

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