From d1846b96c0709aa672806754ae58b321eb9ec19f Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Wed, 12 Feb 2020 10:54:58 +0000 Subject: [PATCH] cope with an ASG instance not having a launch config any more (#57737) --- lib/ansible/modules/cloud/amazon/ec2_asg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_asg.py b/lib/ansible/modules/cloud/amazon/ec2_asg.py index 83e663313b7..05a3fff742b 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_asg.py +++ b/lib/ansible/modules/cloud/amazon/ec2_asg.py @@ -1497,7 +1497,7 @@ def get_instances_by_launch_config(props, lc_check, initial_instances): # Check if migrating from launch_template to launch_config first if 'launch_template' in props['instance_facts'][i]: old_instances.append(i) - elif props['instance_facts'][i]['launch_config_name'] == props['launch_config_name']: + elif props['instance_facts'][i].get('launch_config_name') == props['launch_config_name']: new_instances.append(i) else: old_instances.append(i) @@ -1524,7 +1524,7 @@ def get_instances_by_launch_template(props, lt_check, initial_instances): # Check if migrating from launch_config_name to launch_template_name first if 'launch_config_name' in props['instance_facts'][i]: old_instances.append(i) - elif props['instance_facts'][i]['launch_template'] == props['launch_template']: + elif props['instance_facts'][i].get('launch_template') == props['launch_template']: new_instances.append(i) else: old_instances.append(i)