Skip to content

Instantly share code, notes, and snippets.

@aradhell
Created December 20, 2019 11:14
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 aradhell/11a5a6fe4b5a5216cd5b2b0148f9ae4d to your computer and use it in GitHub Desktop.
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
#!/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