Created
May 21, 2021 13:58
-
-
Save VildMedPap/56e13b8f7503e656a439bbdfb220cd53 to your computer and use it in GitHub Desktop.
AWS: Whitelist current IP address on desired ec2 and the port of your choice
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
INSTANCE_ID="i-xxx" | |
PORT=22 | |
SG_ID=`aws ec2 describe-instance-attribute --instance-id $INSTANCE_ID --attribute groupSet | python -c "import sys, json; print(json.load(sys.stdin)['Groups'][0]['GroupId'])"` | |
CURRENT_IP=`curl -s http://whatismyip.akamai.com/` | |
aws ec2 authorize-security-group-ingress --group-id $SG_ID --protocol tcp --port $PORT --cidr $CURRENT_IP/32 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to have a set of credentials in the
.aws
directory as well as python installed