Using AWS CLI to choose RHEL and Ubuntu AMIs

For managing my AWS resources, I prefer to stick to the AWS CLI. However, until recently, I have relied on the AWS web console to find AMIs.

Today, I finally decided to dive into JMESPath to come up with my own filters for describe-images. Since I typically stick with RHEL and Ubuntu distros, I created an alias for each.

The output looks like this:

$ ami_rhel
--------------------------------------------------------------------
|                          DescribeImages                          |
+--------------+---------------------------------------------------+
|  ami-2051294a|  RHEL-7.2_HVM_GA-20151112-x86_64-1-Hourly2-GP2    |
|  ami-0d28fe66|  RHEL-6.7_HVM_GA-20150714-x86_64-1-Hourly2-GP2    |
|  ami-b18c62da|  RHEL-6.6_HVM_GA-20150601-x86_64-3-Hourly2-GP2    |
|  ami-b0fed2d8|  RHEL-6.6_HVM_GA-20150319-x86_64-1-Hourly2-GP2    |
|  ami-12663b7a|  RHEL-7.1_HVM_GA-20150225-x86_64-1-Hourly2-GP2    |
|  ami-60a1e808|  RHEL-7.0_HVM_GA-20150209-x86_64-1-Hourly2-GP2    |
|  ami-48400720|  RHEL-6.6_HVM_GA-20150128-x86_64-1-Hourly2-GP2    |
|  ami-aed06ac6|  RHEL-6.6_HVM_GA-20141017-x86_64-1-Hourly2-GP2    |
|  ami-a8d369c0|  RHEL-7.0_HVM_GA-20141017-x86_64-1-Hourly2-GP2    |
|  ami-00a11e68|  RHEL-6.5_GA_HVM-20140929-x86_64-11-Hourly2-GP2   |
|  ami-b414e6dc|  RHEL-6.5_GA_HVM-x86_64-6-Hourly2                 |
|  ami-785bae10|  RHEL-7.0_GA_HVM-x86_64-3-Hourly2                 |
|  ami-5b697332|  RHEL-6.5_HVM_GA-x86_64-7-HVM-Hourly2             |
|  ami-63b6910a|  RHEL-6.5_HVM_GA-x86_64-4-HVM-Hourly2             |
|  ami-3218595b|  RHEL-6.4_HVM_GA-x86_64-10-HVM-Hourly2            |
|  ami-9d0b64f4|  RHEL-6.4_GA_HVM-x86_64-7-HVM-Hourly2             |
+--------------+---------------------------------------------------+

Much cleaner. Hope this helps other.