mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[cloud] Return target_group_names where sensible in ec2_asg_facts module (#26078)
If target_group_arns is an empty list, then return an empty target_group_names list. If a connection to elbv2 is not obtainable, then it is not possible to return target_group_names
This commit is contained in:
parent
e49f15d6e4
commit
0e0b91534a
1 changed files with 7 additions and 4 deletions
|
@ -375,10 +375,13 @@ def find_asgs(conn, module, name=None, tags=None):
|
|||
if 'target_group_ar_ns' in asg:
|
||||
asg['target_group_arns'] = asg['target_group_ar_ns']
|
||||
del(asg['target_group_ar_ns'])
|
||||
if elbv2 and asg.get('target_group_arns'):
|
||||
tg_paginator = elbv2.get_paginator('describe_target_groups')
|
||||
tg_result = tg_paginator.paginate(TargetGroupArns=asg['target_group_arns']).build_full_result()
|
||||
asg['target_group_names'] = [tg['TargetGroupName'] for tg in tg_result['TargetGroups']]
|
||||
if asg.get('target_group_arns'):
|
||||
if elbv2:
|
||||
tg_paginator = elbv2.get_paginator('describe_target_groups')
|
||||
tg_result = tg_paginator.paginate(TargetGroupArns=asg['target_group_arns']).build_full_result()
|
||||
asg['target_group_names'] = [tg['TargetGroupName'] for tg in tg_result['TargetGroups']]
|
||||
else:
|
||||
asg['target_group_names'] = []
|
||||
matched_asgs.append(asg)
|
||||
|
||||
return matched_asgs
|
||||
|
|
Loading…
Reference in a new issue