Created
May 6, 2014 04:37
-
-
Save iogi/01f77d9a4959ac1b88f4 to your computer and use it in GitHub Desktop.
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 | |
VPC_ID = 'vpc-xxxxxxxx' | |
conn = boto.ec2.connect_to_region( | |
'ap-northeast-1', | |
aws_access_key_id='<access key>', | |
aws_secret_access_key='<secret access>') | |
sg_elb = conn.create_security_group('elb2', '80,443 from world', VPC_ID) | |
sg_elb.authorize('tcp', 80, 80, '0.0.0.0/0') | |
sg_elb.authorize('tcp', 4443, 443, '0.0.0.0/0') | |
sg_web = conn.create_security_group('web2', 'from elb 80', VPC_ID) | |
sg_web.authorize('tcp', 80, 80, src_group=sg_elb) | |
sg_admin = conn.create_security_group('admin2', 'ssh from office', VPC_ID) | |
sg_admin.authorize('tcp', 22, 22, ['192.168.0.0/24', '10.11.12.13/32']) | |
sg_db = conn.create_security_group('db2', 'from web and admin', VPC_ID) | |
sg_db.authorize('tcp', 3306, 3306, src_group=sg_elb) | |
sg_db.authorize('tcp', 3306, 3306, src_group=sg_admin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment