Last active
August 29, 2015 14:00
-
-
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
This file contains 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
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