Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.