mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07: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:
|
if 'target_group_ar_ns' in asg:
|
||||||
asg['target_group_arns'] = asg['target_group_ar_ns']
|
asg['target_group_arns'] = asg['target_group_ar_ns']
|
||||||
del(asg['target_group_ar_ns'])
|
del(asg['target_group_ar_ns'])
|
||||||
if elbv2 and asg.get('target_group_arns'):
|
if asg.get('target_group_arns'):
|
||||||
|
if elbv2:
|
||||||
tg_paginator = elbv2.get_paginator('describe_target_groups')
|
tg_paginator = elbv2.get_paginator('describe_target_groups')
|
||||||
tg_result = tg_paginator.paginate(TargetGroupArns=asg['target_group_arns']).build_full_result()
|
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']]
|
asg['target_group_names'] = [tg['TargetGroupName'] for tg in tg_result['TargetGroups']]
|
||||||
|
else:
|
||||||
|
asg['target_group_names'] = []
|
||||||
matched_asgs.append(asg)
|
matched_asgs.append(asg)
|
||||||
|
|
||||||
return matched_asgs
|
return matched_asgs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue