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 Mar 14, 2021
1 parent 94af64c commit 64eef7a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- ec2_instance - fix key errors when instance has no tags (https://github.com/ansible-collections/community.aws/pull/476).
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 64eef7a

Please sign in to comment.