Switch aws filters to json in helpers.sh

to fix compat with latest aws-cli
This commit is contained in:
netpro2k 2020-05-06 18:59:00 -07:00
Родитель b82bd24270
Коммит d83179f11b
1 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -23,15 +23,16 @@ function hab-build-and-run {
# moz-ec2 [env] [asg]
# Lists active hosts from EC2, displaying environment, ASG, name, private IP, and public IP.
function moz-ec2 {
local FILTERS="Name=instance-state-name,Values=running"
local FILTERS="[{\"Name\": \"instance-state-name\",\"Values\": [\"running\"]}"
if [ ! -z "$1" ]
then
FILTERS="$FILTERS,Name=tag:env,Values=$1"
FILTERS="$FILTERS,{\"Name\": \"tag:env\",\"Values\": [\"$1\"]}"
fi
if [ ! -z "$2" ]
then
FILTERS="$FILTERS,Name=tag:aws:autoscaling:groupName,Values=$1-$2"
FILTERS="$FILTERS,{\"Name\": \"tag:aws:autoscaling:groupName\",\"Values\":[\"$1-$2\"]}"
fi
FILTERS="$FILTERS]"
local ALL=$(aws ec2 describe-instances --output json --filters "$FILTERS")
local OUTPUT=$(jq -r '.Reservations | map(.Instances) | flatten | .[] | [
((.Tags//[])[]|select(.Key=="env")|.Value) // "null",