Skip to content

Instantly share code, notes, and snippets.

@nhammond101
Last active November 15, 2019 09:20
Show Gist options
  • Save nhammond101/3d11d3e3ee3cd88f7f0b4435e424343a to your computer and use it in GitHub Desktop.
Save nhammond101/3d11d3e3ee3cd88f7f0b4435e424343a to your computer and use it in GitHub Desktop.
Add current IP to AWS EC2 security group for SSH Access using Docker
docker run --rm -it -v ~/.aws:/root/.aws waracle/aws-cli \
aws ec2 \
--profile default \
authorize-security-group-ingress \
--group-id sg-123456780abcdef \
--ip-permissions "FromPort=22,ToPort=22,IpProtocol=tcp,IpRanges=[{CidrIp=$(curl -s https://canihazip.com/s)/32,Description=RoamingIp}]"
@nhammond101
Copy link
Author

nhammond101 commented Nov 15, 2019

  • The docker image is the one Waracle created for our CI boxes and includes the python AWS CLI
  • The profile can be changed to match whichever AWS profile/account you have
  • The group-id is a placeholder and MUST be changed to the security group id you want to add IPs to
  • The IP range description shouldn't include spaces. I haven't figured out to send spaces in the string yet...

@nhammond101
Copy link
Author

Yes, i did spend most of my time thinking of a clever acronym. Pippa stands for Push IP to Aws. I know there's 2 Ps, but it's early

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment