From 7f5aea980af1236ac6707f0f08ed64253b221c38 Mon Sep 17 00:00:00 2001
From: Brandon W Maister <bwm@knewton.com>
Date: Tue, 3 Mar 2015 13:03:08 -0500
Subject: [PATCH] ec2: Apply all security groups at instance-creation

The code was picking out the first instance from the security groups
specified, even when multiple groups were specified. Now we use all of
them.
---
 cloud/amazon/ec2.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/cloud/amazon/ec2.py b/cloud/amazon/ec2.py
index a48eb534b41..2c96d01851e 100755
--- a/cloud/amazon/ec2.py
+++ b/cloud/amazon/ec2.py
@@ -806,8 +806,7 @@ def create_instances(module, ec2, vpc, override_count=None):
             if type(group_id) == str:
                 group_id = [group_id]
             grp_details = ec2.get_all_security_groups(group_ids=group_id)
-            grp_item = grp_details[0]
-            group_name = [grp_item.name]
+            group_name = [grp_item.name for grp_item in grp_details]
     except boto.exception.NoAuthHandlerFound, e:
             module.fail_json(msg = str(e))