dimanche 28 juin 2015

bash/shell jq parse to variable from aws json

I am trying to parse json result from aws result, but I getting error or null when I am using $ip, when I am using specific IP it work. something wrong when I am using tne variable inside the jq command

#!/bin/bash

aws ec2 describe-addresses --region eu-west-1 > 1.txt
ipList=( "52.16.121.238" "52.17.250.188" )

for ip in "${ipList[@]}";
do
    echo $ip
    cat 1.txt | jq '.Addresses | .[] | select (.PublicIp==$ip) |    .InstanceId'
    #echo $result

done

Please advise, Thanks. Cfir.




Aucun commentaire:

Enregistrer un commentaire