From 39ef6a1a80d0bc0c3c2b58d39fb8b59959baa17d Mon Sep 17 00:00:00 2001 From: Keith Hassen Date: Sun, 22 Nov 2015 21:53:21 -0500 Subject: [PATCH] Fail if any group name is not resolved to an ID. --- cloud/amazon/ec2.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cloud/amazon/ec2.py b/cloud/amazon/ec2.py index ac2d58064be..b14c3c7d961 100644 --- a/cloud/amazon/ec2.py +++ b/cloud/amazon/ec2.py @@ -883,6 +883,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: