@@ -595,7 +595,15 @@ def get_security_groups(self, name):
595
595
def get_security_group_id (self , name , vpcid ):
596
596
conn = self .conn
597
597
for sg in conn .describe_security_groups ()['SecurityGroups' ]:
598
- if sg ['VpcId' ] == vpcid and (sg ['GroupName' ] == name or sg ['GroupId' ] == name ):
598
+ group_name = sg ['GroupName' ]
599
+ group_id = sg ['GroupId' ]
600
+ group_tag = sg ['GroupId' ]
601
+ group_name = ''
602
+ for tag in sg .get ('Tags' , []):
603
+ if tag ['Key' ] == 'Name' :
604
+ group_name = tag ['Value' ]
605
+ break
606
+ if sg ['VpcId' ] == vpcid and (group_name == name or group_id == name or group_tag == name ):
599
607
return sg ['GroupId' ]
600
608
return None
601
609
@@ -1725,7 +1733,12 @@ def list_security_groups(self, network=None):
1725
1733
for sg in conn .describe_security_groups ()['SecurityGroups' ]:
1726
1734
if vpcid is not None and sg ['VpcId' ] != vpcid :
1727
1735
continue
1728
- results .append (sg ['GroupName' ])
1736
+ group_name = sg ['GroupName' ]
1737
+ for tag in sg .get ('Tags' , []):
1738
+ if tag ['Key' ] == 'Name' :
1739
+ group_name = tag ['Value' ]
1740
+ break
1741
+ results .append (group_name )
1729
1742
return results
1730
1743
1731
1744
def create_security_group (self , name , overrides = {}):
0 commit comments