Commit 22de696a by Feanil Patel

Figure out the security group for the play by tag instead of getting it passed in.

parent 2ab4a2d0
......@@ -172,8 +172,6 @@ def parse_args():
parser.add_argument('-t', '--instance-type', required=False,
default="m1.large",
help="instance type to launch")
parser.add_argument("--security-group", required=False,
default="abbey", help="Security group to use")
parser.add_argument("--role-name", required=False,
default="abbey",
help="IAM role name to use (must exist)")
......@@ -198,27 +196,22 @@ def parse_args():
return parser.parse_args()
def get_instance_sec_group(vpc_id, security_group):
def get_instance_sec_group(vpc_id):
security_group_id = None
grp_details = ec2.get_all_security_groups(
filters={
'vpc_id':vpc_id
'vpc_id':vpc_id,
'tag:play': args.play
}
)
for grp in grp_details:
if grp.name == security_group:
security_group_id = grp.id
break
if not security_group_id:
print "Unable to lookup id for security group {}".format(
security_group)
sys.exit(1)
if len(grp_details) < 1:
sys.stderr.write("ERROR: Expected atleast one security group, got {}\n".format(
len(gry_details)))
return security_group_id
return grp_details[0].id
def create_instance_args():
......@@ -233,16 +226,16 @@ def create_instance_args():
subnet = vpc.get_all_subnets(
filters={
'tag:aws:cloudformation:stack-name': stack_name,
'tag:Application': args.application}
'tag:play': args.play}
)
if len(subnet) != 1:
sys.stderr.write("ERROR: Expected 1 admin subnet, got {}\n".format(
if len(subnet) < 1:
sys.stderr.write("ERROR: Expected at least one subnet, got {}\n".format(
len(subnet)))
sys.exit(1)
subnet_id = subnet[0].id
vpc_id = subnet[0].vpc_id
security_group_id = get_instance_sec_group(vpc_id, args.security_group)
security_group_id = get_instance_sec_group(vpc_id)
if args.identity:
config_secure = 'true'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment