From c4303804bff45b0ea53996acf6f71acf2920ffc2 Mon Sep 17 00:00:00 2001 From: Will Thames Date: Thu, 23 Aug 2018 03:51:59 +1000 Subject: [PATCH] Ensure that target group ports are cast to int on creation (#44442) A previous fix fixed this for existing target groups but not for new target groups Fixes #37368 --- lib/ansible/modules/cloud/amazon/elb_target_group.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/amazon/elb_target_group.py b/lib/ansible/modules/cloud/amazon/elb_target_group.py index f56f9e7bcf9..7b42c6d2059 100644 --- a/lib/ansible/modules/cloud/amazon/elb_target_group.py +++ b/lib/ansible/modules/cloud/amazon/elb_target_group.py @@ -429,6 +429,10 @@ def create_or_update_target_group(connection, module): if params['TargetType'] == 'ip': fail_if_ip_target_type_not_supported(module) + # Correct type of target ports + for target in params['Targets']: + target['Port'] = int(target.get('Port', module.params.get('port'))) + # Get target group tg = get_target_group(connection, module) @@ -515,7 +519,7 @@ def create_or_update_target_group(connection, module): instances_to_add = [] for target in params['Targets']: if target['Id'] in add_instances: - instances_to_add.append({'Id': target['Id'], 'Port': int(target.get('Port', module.params.get('port')))}) + instances_to_add.append({'Id': target['Id'], 'Port': target['Port']}) changed = True try: