Skip to content

Instantly share code, notes, and snippets.

@doi-t
Last active July 5, 2019 00:32
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 doi-t/54ed89c902a6df0ab954c55ee5c1e4f0 to your computer and use it in GitHub Desktop.
Save doi-t/54ed89c902a6df0ab954c55ee5c1e4f0 to your computer and use it in GitHub Desktop.
#!/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