From 4eb0e510e8f01ce85b80cad6420fbd0e5aaaab78 Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Sun, 14 Mar 2021 12:34:12 +0100 Subject: [PATCH] fix KeyError: 'Tags' for ec2_instance (#476) * fix key error when ec2 instance has no tags * add changelog fragment --- plugins/modules/ec2_instance.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/ec2_instance.py b/plugins/modules/ec2_instance.py index 380e3527910..18af847aed6 100644 --- a/plugins/modules/ec2_instance.py +++ b/plugins/modules/ec2_instance.py @@ -889,7 +889,7 @@ def tower_callback_script(tower_conf, windows=False, passwd=None): def manage_tags(match, new_tags, purge_tags, ec2): changed = False - old_tags = boto3_tag_list_to_ansible_dict(match['Tags']) + old_tags = boto3_tag_list_to_ansible_dict(match.get('Tags', {})) tags_to_set, tags_to_delete = compare_aws_tags( old_tags, new_tags, purge_tags=purge_tags, @@ -1559,7 +1559,7 @@ def change_instance_state(filters, desired_state, ec2=None): def pretty_instance(i): instance = camel_dict_to_snake_dict(i, ignore_list=['Tags']) - instance['tags'] = boto3_tag_list_to_ansible_dict(i['Tags']) + instance['tags'] = boto3_tag_list_to_ansible_dict(i.get('Tags', {})) return instance