Skip to content

Instantly share code, notes, and snippets.

@cgswong
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save cgswong/263f1a731a5ca4b2e8f7 to your computer and use it in GitHub Desktop.

Select an option

Save cgswong/263f1a731a5ca4b2e8f7 to your computer and use it in GitHub Desktop.
Get AWS AMI ID for CoreOS channels
#!/bin/bash
# CoreOS channel ["stable" | "beta" | "alpha"]
channel=${1:-"alpha"}
# AWS AMI disk backing ["pv" | "hvm"]
disk=hvm
# Use default us-east-1 region
region=${2:-"us-east-1"}
ami_id=$(curl --silent --location http://$channel.release.core-os.net/amd64-usr/current/coreos_production_ami_all.json | grep -A 2 $region | grep $disk | cut -d"\"" -f4)
[ -z "$ami_id" ] && echo "FAIL: region $region not found or doesn't include a $channel, $disk backed CoreOS AMI" && exit 1
echo "channel,region,build,disk,id,ami,url"
echo "$channel,$region,$build,$disk,$ami_id,https://console.aws.amazon.com/ec2/home?region=$region#launchAmi=$ami_id"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment