Determine which AutoScaling Group a Launch Configuration is attached to

Tag: amazon-web-services , autoscaling Author: odi415287 Date: 2013-06-23

Question: Is there a way to determine which AutoScaling Group a Launch Configuration is attached to.

Why do I need to know? I have a list of existing Launch Configurations and I want to delete one of them.

Undesirable Solutions:

  • I can get a list of all my AutoScaling Groups and look through each one to determine which Launch Configuration it is using.
  • I can just try to delete the Launch Configuration and then having the error tell me which AutoScaling Group it is attached to.

Desirable Solutions:

  • Query Launch Configuration and have it return which group it is attached to.
  • Query all AutoScaling Groups with the Launch Configuration name as a filter.

Best Answer

The answer as of this moment is that the solution I am looking for does not yet exist.

In light of this current lack I have proceeded to evaluate my Undesirable Solutions.

I first considered using a try/catch|except block and parsing the error when trying to delete a Launch Configuration that was attached to a group. The cost of parsing was more than I wanted to deal with so I decided to go with looping through the AutoScaling Groups and finding a match for each individual Launch Configuration.

While the solution is less than ideal, it is working quite nicely. I hope to post the code on GitHub shortly so that others can also benefit from it.

Update: 07 August 2013

Here is some code on GitHub that I have been working on. Hope it is helpful to others.