Skip to content

Commit

Permalink
fix KeyError: 'Tags' for ec2_instance (ansible-collections#476)
Browse files Browse the repository at this point in the history
* fix key error when ec2 instance has no tags
* add changelog fragment
  • Loading branch information
markuman authored and jillr committed Mar 14, 2021
1 parent 220ca6c commit 4eb0e51
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/modules/ec2_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 4eb0e51

Please sign in to comment.