Skip to content

Commit

Permalink
support version 1.3.8 of AWS CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Uri Agassi committed Jul 7, 2014
1 parent e28cadd commit 67d1b5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
12 changes: 6 additions & 6 deletions sash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@ 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
fi
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[@]}))

Expand Down

0 comments on commit 67d1b5b

Please sign in to comment.