Skip to content

Instantly share code, notes, and snippets.

@apoorvparijat
Created December 24, 2018 09:37
Show Gist options
  • Select an option

  • Save apoorvparijat/b874d959cc08cf757c5b39a4e6330c85 to your computer and use it in GitHub Desktop.

Select an option

Save apoorvparijat/b874d959cc08cf757c5b39a4e6330c85 to your computer and use it in GitHub Desktop.
Update Security Group Rule
#!/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