Last active
August 29, 2015 14:10
-
-
Save chriskacerguis/368c7fd0e17e02ddf9c7 to your computer and use it in GitHub Desktop.
Create a security group in AWS via Ruby AWS SDK
This file contains hidden or 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
# Written by Chris Kacerguis | |
# AWS Credentials | |
ec2 = AWS::EC2.new( | |
:access_key_id => 'YOUR_ACCESS_KEY_ID', | |
:secret_access_key => 'YOUR_SECRET_ACCESS_KEY') | |
secgrp = ec2.security_groups.create('NAME_OF_SECURITY_GROUP') | |
# EXAMPLE: single port | |
secgrp.authorize_ingress(:tcp, 80) | |
# EXAMPLE: port range | |
secgrp.authorize_ingress(:tcp, 0..65000) | |
# EXAMPLE: single port with specific IPs | |
secgrp.authorize_ingress(:tcp, 22, '1.1.1.1/0', '2.2.2.2/0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment