All these assume OSX bash. Most should be portable to Linux.
brew install spark
to get the nifty sparklines stuff
Price history of the last 12 hours of c5.18xlarge instances
aws ec2 describe-spot-price-history --instance-types c5.18xlarge --product-descriptions "Linux/UNIX" --start-time $(date -v-12H -u +"%Y-%m-%dT%H:%M:%S.000Z") --query "SpotPriceHistory[].SpotPrice" --output text
As a sparkline:
$ aws ec2 describe-spot-price-history --instance-types c5.18xlarge --product-descriptions "Linux/UNIX" --start-time $(date -v-12H -u +"%Y-%m-%dT%H:%M:%S.000Z") --query "SpotPriceHistory[].SpotPrice" --output text | spark
▁▁▁█▁▁▁▁▁
Which region has the best spot price for a particular instance type?
aws ec2 describe-spot-price-history --instance-types m4.4xlarge --product-descriptions "Linux/UNIX" --start-time $(date -v-1H -u +"%Y-%m-%dT%H:%M:%S.000Z") --query "SpotPriceHistory[*].[AvailabilityZone,SpotPrice]|sort_by(@,&[1])|[0][0]" --output text
Generate a list of hosts for an EMR cluster EMR won't generate public DNS names for the individual nodes in an EMR cluster. You can generate a list of the DNS entries for the machines in an EMR cluster and merge them into /etc/hosts so the links in the hadoop console are navigable.
CLUSTER_ID=$(aws emr list-clusters --active --query "Clusters[?Name=='$CLUSTER_NAME'].Id" --output text)
echo "Cluster id is '$CLUSTER_ID'"
aws emr list-instances --cluster-id $CLUSTER_ID \
--query 'Instances[?PrivateIpAddress!="None"].{ip:PrivateIpAddress,dns:PrivateDnsName}' \
--output text | awk '{ print $2 "\t" $1}' > ~/emr-hosts
# merge ~/emr-hosts with /etc/hosts
Filter a list of ELB Target Groups by a name prefix
aws --profile dev elbv2 describe-target-groups --query 'TargetGroups[?starts_with(TargetGroupName,`dev`)].{TargetGroupArn:TargetGroupArn,TargetGroupName:TargetGroupName}'
https://opensourceconnections.com/blog/2015/07/27/advanced-aws-cli-jmespath-query/