From f5f7a8c681c486c94c697173c7b4f50e6db6664b Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Thu, 30 Mar 2017 14:55:31 -0400 Subject: [PATCH] [cloud] only create new eni if none of the filters lead to one match (#22919) --- lib/ansible/modules/cloud/amazon/ec2_eni.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_eni.py b/lib/ansible/modules/cloud/amazon/ec2_eni.py index dbc136f8ba..37dde52d25 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_eni.py +++ b/lib/ansible/modules/cloud/amazon/ec2_eni.py @@ -483,9 +483,6 @@ def find_eni(connection, module): instance_id = module.params.get('instance_id') device_index = module.params.get('device_index') - if not eni_id: - return None - try: filters = {} if subnet_id: @@ -499,7 +496,7 @@ def find_eni(connection, module): filters['attachment.device-index'] = device_index eni_result = connection.get_all_network_interfaces(eni_id, filters=filters) - if len(eni_result) > 0: + if len(eni_result) == 1: return eni_result[0] else: return None