Created
December 20, 2019 11:14
-
-
Save aradhell/11a5a6fe4b5a5216cd5b2b0148f9ae4d to your computer and use it in GitHub Desktop.
bash script to add ip addresses from json list to ec2 security group
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/sh | |
#AWS_IP=$(curl https://dnsjson.com/nat.gce-us-central1.travisci.net/A.json) | |
curl https://dnsjson.com/nat.gce-us-central1.travisci.net/A.json | jq -r '.results.records[]' | while read id ; do | |
aws ec2 authorize-security-group-ingress --region eu-west-1 --group-name sg-group-name \ | |
--protocol tcp --port 3306 \ | |
--cidr "${id}"/32 | |
done | |
curl https://dnsjson.com/nat.gce-us-east1.travisci.net/A.json | jq -r '.results.records[]' | while read id ; do | |
aws ec2 authorize-security-group-ingress --region eu-west-1 --group-name sg-group-name \ | |
--protocol tcp --port 3306 \ | |
--cidr "${id}"/32 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment