Created
August 11, 2016 21:08
-
-
Save darron/f925339ff7aa458c53634dc236409013 to your computer and use it in GitHub Desktop.
If you've got a lot of security groups and you need Consul to connect to each - here's the brute force way to do it.
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 | |
# Make a list of all security groups - one on each line. | |
# Save as `security-groups.txt` | |
# Yes this would be easier in VPC or by launching with multiple Security Groups | |
# but you might not have that option and you might have to do this. | |
SGROUPS=$(cat security-groups.txt) | |
for SG in $SGROUPS; | |
do | |
echo "===== Working on '$SG' =====" | |
for ILOOP in $SGROUPS; | |
do | |
echo "$SG with $ILOOP" | |
aws ec2 authorize-security-group-ingress --group-id $SG --protocol tcp --port 8300-8301 --source-group $ILOOP | |
aws ec2 authorize-security-group-ingress --group-id $SG --protocol udp --port 8300-8301 --source-group $ILOOP | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment