Skip to content

Instantly share code, notes, and snippets.

@calum-github
Last active September 27, 2018 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calum-github/d04a826dd249172b880bd22ad0b3539c to your computer and use it in GitHub Desktop.
Save calum-github/d04a826dd249172b880bd22ad0b3539c to your computer and use it in GitHub Desktop.
Get a list of AWS AMI codes for CentOS 7 Linux
#!/bin/bash
# Get latest AMI codes for CentOS 7 from AWS
region="ap-southeast-2"
product_code="aw0evgkw8e5c1q413zgy5pjce"
aws ec2 describe-images \
--region "$region" \
--owners aws-marketplace \
--filters Name=product-code,Values="$product_code" \
--query 'Images[*].[CreationDate,Name,ImageId]' \
--filters "Name=name,Values=CentOS Linux 7*" \
--output table | sort -r
@calum-github
Copy link
Author

Get the product code from CentOS from here:
https://wiki.centos.org/Cloud/AWS

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