Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ec2_instance - Fix NoneType error on no input tags #856

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- ec2_instance - fix NoneType error when no tags are input (https://github.com/ansible-collections/amazon.aws/pull/856).
jatorcasso marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 2 additions & 3 deletions plugins/modules/ec2_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1780,17 +1780,16 @@ def determine_iam_role(name_or_arn):


def handle_existing(existing_matches, state):
tags = dict(module.params.get('tags', None))
tags = dict(module.params.get('tags') or {})
jatorcasso marked this conversation as resolved.
Show resolved Hide resolved
purge_tags = module.params.get('purge_tags')
name = module.params.get('name')

# Name is a tag rather than a direct parameter, we need to inject 'Name'
# into tags, but since tags isn't explicitly passed we'll treat it not being
# set as purge_tags == False
if name:
if purge_tags and tags is None:
if purge_tags and not tags:
jatorcasso marked this conversation as resolved.
Show resolved Hide resolved
purge_tags = False
tags = {}
tags.update({'Name': name})
jatorcasso marked this conversation as resolved.
Show resolved Hide resolved

changed = False
Expand Down