small pixel drawing of a pufferfish dotfiles

bin/MACC02VK5ECHTD7/jws-fetch

#!/bin/sh

date=$(date +%s)
for r in us-east-1 us-west-2; do
    for p in browse cgraph; do
        for e in test stage prod; do
        dir="$HOME/.jws/${r}/${p}/${e}"
        mkdir -p "$dir"
            echo "Fetching ${r}/${p}/${e}"
            aws ec2 describe-instances --profile "${p}_${e}" --region "$r" --output text --query "Reservations[*].Instances[*].{
                    Instance:InstanceId,
                    Type:InstanceType,
                    AZ:Placement.AvailabilityZone,
                    Name:Tags[?Key==\`Name\`]|[0].Value,
                    pubIP:PublicIpAddress,
                    IP:PrivateIpAddress,
                    State:State.Name,
                    VPC:VpcId
            }" | sed "s/$/    ${p}_${e}/" > "$dir/$date" &
            # add profile to end for easy greppin'
            # link current for other scripts
            ln -fs "$dir/$date" "$dir/current"
        done
    done
done

wait