· aws til

Searching through AWS Icons

I recently needed to search for an icon in the AWS [asset package](https://aws.amazon.com/architecture/icons/) and wanted to share a little script that I wrote. You wouldn’t think that searching for icons should be that hard, but they’re spread across so many folders and sub-folders that you can spend forever trying to find what you want.

First, let’s import some modules:

import base64
import sys
import glob
import os

And then I’m using the following function to render images in the terminal:

def display_image(image_path):
    with open(image_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read()).decode()
        print(f'\x1b]1337;File=inline=1:{encoded_string}\a', end="")

Next, we have a function that does a recursive glob search of the unpacked asset package and returns matching files and what the icon looks like:

def search_icons(search_term):
    files = glob.glob(f"**/*{search_term}*", recursive=True)
    files = [file for file in files if os.path.isfile(file)]
    for file in files:
        display_image(file); print(file)

Let’s give ie a try:

search_icons("[Vv]irtual-Machine")
search aws icons
  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket