Skip to content

Instantly share code, notes, and snippets.

@angrychimp
Last active March 21, 2018 18:15
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 angrychimp/1b1a33bb13bf4943a178b045870cd003 to your computer and use it in GitHub Desktop.
Save angrychimp/1b1a33bb13bf4943a178b045870cd003 to your computer and use it in GitHub Desktop.
An example of how to use a `bash` script to perform actions on AMI records
#!/bin/bash
IFS=$'\n'
for image in $(aws ec2 describe-images --filter "Name=description,Values=Auto backed up on *" --query 'Images[].{Description:Description,Image_ID:ImageId,DateCreated:CreationDate}')
creationDate=$(echo $image | awk -F'\t' '{print $1}')
description=$(echo $image | awk -F'\t' '{print $2}')
imageId=$(echo $image | awk -F'\t' '{print $3}')
echo "$imageId | $creationDate | $description"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment