Merge pull request #2512 from erewh0n/ec2-require-all-groups
Fail ec2 module when group names cannot resolve to IDs
This commit is contained in:
commit
5617cd57cf
1 changed files with 3 additions and 0 deletions
|
@ -891,6 +891,9 @@ def create_instances(module, ec2, vpc, override_count=None):
|
|||
grp_details = ec2.get_all_security_groups()
|
||||
if isinstance(group_name, basestring):
|
||||
group_name = [group_name]
|
||||
unmatched = list(set(group_name) - set([str(grp.name) for grp in grp_details]))
|
||||
if len(unmatched) > 0:
|
||||
module.fail_json(msg="the following group names are not valid: %s" % ','.join(unmatched))
|
||||
group_id = [ str(grp.id) for grp in grp_details if str(grp.name) in group_name ]
|
||||
# Now we try to lookup the group id testing if group exists.
|
||||
elif group_id:
|
||||
|
|
Loading…
Reference in a new issue