github twitter linkedin
Add Missing Tags to ELBs
Oct 18, 2018
2 minutes read

At my current employer we have grown really fast in AWS and learned a lot of things along the way. A couple big lessons:

  1. We don’t always do things the correct way from the beginning
  2. As costs grow, it becomes important to identify where those costs are

With respect to the first point, we created a lot of things without applying tags we thought were important. One of those tags identifies the Environment a resource is used for. Any resource could be used for DEV, QA, PROD or one of a few other values.

Unfortunately, we weren’t always dilligent with tagging our resources with this information. Hindsight is always 2020, but looking back now, that information is extremely useful when you’re trying to figure out where your 5 figure monthly bill is going! Which brings me to the second point.

For some things, like the gobs of untagged EBS volumes, it was easy to get the tags right with Cloud Custodian. The Cloud Custodian project has a policy that will copy tags from an EC2 instance to any attached volume, but, it doesn’t have a policy that will do something similar for ELBs. By the way, if you haven’t checked out the Cloud Custodian project, I highly recommend it as a way of enforcing various policies and keeping things clean.

To solve the issue with untagged ELBs, I decided to write my own Python scripts that can be used as Lambda functions in AWS. I made the scripts available on GitLab as snippets.

Check them out, and I welcome any suggestions to improve them! You can respond to me via the commentson the snippets.

Tags: aws python

Back to posts