Skip to content

Instantly share code, notes, and snippets.

@darron
Created August 11, 2016 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darron/f925339ff7aa458c53634dc236409013 to your computer and use it in GitHub Desktop.
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.
#!/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