Skip to content

Instantly share code, notes, and snippets.

@thara
Created May 24, 2014 08:55
Show Gist options
  • Select an option

  • Save thara/ab8fedfb217327f60469 to your computer and use it in GitHub Desktop.

Select an option

Save thara/ab8fedfb217327f60469 to your computer and use it in GitHub Desktop.
#!/bin/sh
instanceType=t1.micro
region=ap-northeast-1
availabilityZone=${region}b
productDescription=Linux/UNIX
offeringType="Linux Utilization"
duration=$((60*60*24*365))
filters=`cat <<EOS
[
{
"Name": "instance-type",
"Values": ["${instanceType}"]
},
{
"Name": "availability-zone",
"Values": ["${availabilityZone}"]
},
{
"Name": "duration",
"Values": ["${duration}"]
},
{
"Name": "product-description",
"Values": ["${productDescription}"]
}
]
EOS`
# echo \'$filters\'
echo $filters | xargs -0 aws ec2 describe-reserved-instances \
--offering-type "${offeringType}" \
--filters \
| jq '.ReservedInstancesOfferings[].ReservedInstancesOfferringID'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment