Automatically add current public IP to Security Group to allow traffic on specific port

I believe there are multiple ways of doing this. But I can share the way i have been doing this for a while using Python. I have no experience with OSX but i would assume it comes pre-installed with Python, so you should be able to do this. One caveat though, i had to install the boto, which is a Python interface to AWS for API calls. Definitely you can also accomplish the same thing with EC2 CLI Tools.

Boto installation instructions can be found here -

http://boto.readthedocs.org/en/latest/getting_started.html

import boto.ec2
conn=boto.ec2.connect_to_region('us-east-1')
conn.authorize_security_group(group_name='my_sec_group', ip_protocol='tcp', from_port='22', to_port='22', cidr_ip='1.2.3.4/32')

Steps -

Import the necessary module
Connect to any region
Use authorize_security_group and specify the security group name, protocol, to/from port and your IP.