Last active
July 5, 2019 00:32
-
-
Save doi-t/54ed89c902a6df0ab954c55ee5c1e4f0 to your computer and use it in GitHub Desktop.
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 | |
[ $# -ne 1 ] && echo "Usage: $0 <security group id>" && exit 1 | |
SG_ID=$1 | |
MY_IP=$(dig +short myip.opendns.com @resolver1.opendns.com) | |
aws ec2 authorize-security-group-ingress --group-id ${SG_ID} \ | |
--ip-permissions IpProtocol=tcp,FromPort=22,ToPort=22,IpRanges="[{CidrIp=${MY_IP}/32,Description='Open 22 port with awscli'}]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment