Created
July 9, 2018 19:47
-
-
Save serkanh/e007fb7550492c5c1eff3a3bfdcf9416 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html | |
amazon_ips=( $(curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.service=="AMAZON") | .ip_prefix') ) | |
ec2_ips=( $(curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.service=="EC2") | .ip_prefix') ) | |
containsElement () { | |
local element match="$1" | |
shift | |
for element | |
do [[ "$element" == "$match" ]] && return 0; done | |
return 1 | |
} | |
for ip in "${amazon_ips[@]}" | |
do | |
if ! containsElement "$ip" "${ec2_ips[@]}" | |
then | |
echo $ip | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment