Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.85 KB | None | 0 0
  1. # Get initial values
  2. AZS=( ${availability_zones} )
  3. declare -a RESULTS=()
  4.  
  5. # Loop through each AZ to find instance IPs
  6. for zone in "$${AZS[@]}"; do
  7.  
  8.     echo "> Get Consul seeds from AWS $zone"
  9.     NUM_SEEDS=0
  10.     while [[ $NUM_SEEDS -lt $((${min_cluster_size_consul} / 3)) ]]; do
  11.         SEEDS=`aws ec2 describe-instances --filters \
  12.             "Name=availability-zone,Values=$zone" \
  13.             "Name=tag:Name,Consul=Server" \
  14.             "Name=tag:Environment,Values=${environment}"`
  15.         NUM_SEEDS=`echo $SEEDS | jq '{Reservations}[] | length'`
  16.         echo "> NUM_SEEDS: $NUM_SEEDS"
  17.         sleep 1
  18.     done
  19.  
  20.     RESULTS+=( `echo $SEEDS | jq -r '.Reservations[].Instances[].NetworkInterfaces[].PrivateIpAddresses[].PrivateIpAddress'` )
  21.  
  22. done
  23.  
  24. # Don't look
  25. RETRYJOIN="-retry-join=$${RESULTS[0]}$(printf " -retry-join=%s" "$${RESULTS[@]:1}")"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement