Skip to content

Commit

Permalink
Merge pull request #200 from FliesLikeABrick/feature/support-sg-id
Browse files Browse the repository at this point in the history
Improvement for #186 in beeswithmachineguns, accept sg ID and name
  • Loading branch information
cosmin committed Nov 29, 2017
2 parents c358364 + 21ef2b1 commit 85fd986
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions beeswithmachineguns/bees.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,19 @@ def _get_region(zone):
return zone if 'gov' in zone else zone[:-1] # chop off the "d" in the "us-east-1d" to get the "Region"

def _get_security_group_id(connection, security_group_name, subnet):
"""Takes a security group name and returns the ID. If the name cannot be found, the name will be attempted
as an ID. The first group found by this name or ID will be used."""
if not security_group_name:
print('The bees need a security group to run under. Need to open a port from where you are to the target subnet.')
return

security_groups = connection.get_all_security_groups(filters={'group-name': [security_group_name]})

if not security_groups:
print('The bees need a security group to run under. The one specified was not found.')
return
security_groups = connection.get_all_security_groups(filters={'group-id': [security_group_name]})
if not security_groups:
print('The bees need a security group to run under. The one specified was not found.')
return

return security_groups[0].id if security_groups else None

Expand Down

0 comments on commit 85fd986

Please sign in to comment.