Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ec2_launch_template doesn't process arguments correctly
  • Loading branch information
falsedlah committed Sep 20, 2021
1 parent 3d74527 commit ce77b4f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion plugins/modules/ec2_launch_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,22 @@ def delete_template(module):
return {'changed': False}


def remove_none(obj):
if isinstance(obj, (list, tuple, set)):
return type(obj)(remove_none(x) for x in obj if x is not None)
elif isinstance(obj, dict):
return type(obj)((remove_none(k), remove_none(v))
for k, v in obj.items() if k is not None and v is not None)
else:
return obj


def create_or_update(module, template_options):
ec2 = module.client('ec2', retry_decorator=AWSRetry.jittered_backoff(catch_extra_error_codes=['InvalidLaunchTemplateId.NotFound']))
template, template_versions = existing_templates(module)
out = {}
lt_data = params_to_launch_data(module, dict((k, v) for k, v in module.params.items() if k in template_options))
lt_data = remove_none(lt_data)
if not (template or template_versions):
# create a full new one
try:
Expand Down Expand Up @@ -705,4 +716,4 @@ def main():


if __name__ == '__main__':
main()
main()

0 comments on commit ce77b4f

Please sign in to comment.