From 67d1b5b0e0f7c2cfde21ed1bad591afc9fc8e341 Mon Sep 17 00:00:00 2001 From: Uri Agassi Date: Mon, 7 Jul 2014 15:01:52 +0300 Subject: [PATCH] support version 1.3.8 of AWS CLI (https://github.com/aws/aws-cli/issues/758) --- README.md | 2 +- sash.sh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 40a259c..0876978 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ sash Prerequisites ------------- -1. Install [AWS Unified CLI](https://github.com/aws/aws-cli) +1. Install [AWS Unified CLI](https://github.com/aws/aws-cli) (make sure you have installed version 1.3.8 or later) 2. Make sure you have `AWS_ACCESS_KEY`, `AWS_SECRET_KEY` and `AWS_DEFAULT_REGION` set in your environment 3. Put all your PEM files under `~/.aws` diff --git a/sash.sh b/sash.sh index d2cb6ef..41dc961 100644 --- a/sash.sh +++ b/sash.sh @@ -39,10 +39,10 @@ function sash { ip_scope=PublicIpAddress fi - local instance=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=$host" "Name=instance-state-name,Values=running" --query "Reservations[*].Instances[].[KeyName,$ip_scope,Tags[?Key==\`Name\`].Value,InstanceId,Tags[?Key==\`SashUserName\`].Value]" --output text) + local instance=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=$host" "Name=instance-state-name,Values=running" --query "Reservations[*].Instances[].[KeyName,$ip_scope,Tags[?Key==\`Name\`].Value | [0],InstanceId,Tags[?Key==\`SashUserName\`].Value | [0]]" --output text) if [[ -z $instance ]]; then - instance=$(aws ec2 describe-instances --filters "Name=private-ip-address,Values=$host" "Name=instance-state-name,Values=running" --query "Reservations[*].Instances[].[KeyName,$ip_scope,Tags[?Key==\`Name\`].Value,InstanceId,Tags[?Key==\`SashUserName\`].Value]" --output text) + instance=$(aws ec2 describe-instances --filters "Name=private-ip-address,Values=$host" "Name=instance-state-name,Values=running" --query "Reservations[*].Instances[].[KeyName,$ip_scope,Tags[?Key==\`Name\`].Value | [0],InstanceId,Tags[?Key==\`SashUserName\`].Value | [0]]" --output text) if [[ -z $instance ]]; then echo Could not find an instance named $host return 1 @@ -50,13 +50,13 @@ function sash { fi local instances_data local default_user=${SASH_DEFAULT_USER:-ubuntu} - read -a instances_data <<< ${instance//\[\]/$default_user} + read -a instances_data <<< ${instance} eval $(_get_data pems 0 ${instances_data[@]}) eval $(_get_data ips 1 ${instances_data[@]}) - eval $(_get_data hosts 2 ${instances_data[@]//[\'\[\]]/}) - eval $(_get_data resource_ids 3 ${instances_data[@]//[\'\[\]]/}) - eval $(_get_data users 4 ${instances_data[@]//[\'\[\]]/}) + eval $(_get_data hosts 2 ${instances_data[@]}) + eval $(_get_data resource_ids 3 ${instances_data[@]}) + eval $(_get_data users 4 ${instances_data[@]//None/$default_user}) local number_of_instances=$((${#ips[@]}))