Skip to content

Instantly share code, notes, and snippets.

@slibby
Last active August 29, 2015 14:00
Show Gist options
  • Save slibby/11267740 to your computer and use it in GitHub Desktop.
Save slibby/11267740 to your computer and use it in GitHub Desktop.
Create new security group in EC2 from list of IP address/CIDR blocks
import boto.ec2
conn = boto.ec2.connect_to_region("us-west-1",
aws_access_key_id='',
aws_secret_access_key='')
web = conn.create_security_group('NewSG','New Security Group')
ips ="0.0.0.0/0,1.1.1.1/32" #etc
ips = ipranges.split(',')
for ip in ips:
web.authorize('tcp',443,443,ip)
for ip in ips:
web.authorize('tcp',80,80,ip)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment