diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_asg_facts.py b/lib/ansible/modules/extras/cloud/amazon/ec2_asg_facts.py index 857d0c20a0..d6eb1dc611 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_asg_facts.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_asg_facts.py @@ -299,7 +299,11 @@ def find_asgs(conn, module, name=None, tags=None): module.fail_json(msg=e.message, **camel_dict_to_snake_dict(e.response)) matched_asgs = [] - name_prog = re.compile(r'^' + name) + + if name is not None: + # if the user didn't specify a name + name_prog = re.compile(r'^' + name) + for asg in asgs['AutoScalingGroups']: if name: matched_name = name_prog.search(asg['AutoScalingGroupName'])