Created
December 24, 2018 09:37
-
-
Save apoorvparijat/b874d959cc08cf757c5b39a4e6330c85 to your computer and use it in GitHub Desktop.
Update Security Group Rule
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 | |
| PREVIOUS_IP=`cat previous-ip.txt` | |
| aws ec2 revoke-security-group-ingress \ | |
| --region ap-south-1 \ | |
| --group-id sg-01d93e4e5fd0fe634 \ | |
| --protocol -1 \ | |
| --cidr $PREVIOUS_IP | |
| PUBLIC_IP=`curl --silent v4.ifconfig.co | awk '{ print $0 "/32" }'` | |
| aws ec2 authorize-security-group-ingress \ | |
| --region ap-south-1 \ | |
| --group-id sg-01d93e4e5fd0fe634 \ | |
| --protocol -1 \ | |
| --cidr $PUBLIC_IP | |
| echo $PUBLIC_IP > previous-ip.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment