From cca24b0eac02985a687021dd9aaf218256a92234 Mon Sep 17 00:00:00 2001 From: Allen Sanabria Date: Mon, 25 Jul 2016 14:08:40 -0700 Subject: [PATCH] Make sure to catch if no gateways exist --- lib/ansible/modules/extras/cloud/amazon/ec2_vpc_nat_gateway.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_nat_gateway.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_nat_gateway.py index 3d11e372463..b8e90f73a59 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_nat_gateway.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_nat_gateway.py @@ -342,6 +342,7 @@ def get_nat_gateways(client, subnet_id=None, nat_gateway_id=None, params = dict() err_msg = "" gateways_retrieved = False + existing_gateways = list() if not states: states = ['available', 'pending'] if nat_gateway_id: @@ -361,14 +362,12 @@ def get_nat_gateways(client, subnet_id=None, nat_gateway_id=None, try: if not check_mode: gateways = client.describe_nat_gateways(**params)['NatGateways'] - existing_gateways = list() if gateways: for gw in gateways: existing_gateways.append(convert_to_lower(gw)) gateways_retrieved = True else: gateways_retrieved = True - existing_gateways = [] if nat_gateway_id: if DRY_RUN_GATEWAYS[0]['nat_gateway_id'] == nat_gateway_id: existing_gateways = DRY_RUN_GATEWAYS