mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
[ec2_asg_facts] Add exception handling to describing the target groups in case they are in the process of being deleted. (#33997)
This commit is contained in:
committed by
Ryan Brown
parent
ae5c370737
commit
f0cf1b35d5
@@ -370,9 +370,13 @@ def find_asgs(conn, module, name=None, tags=None):
|
||||
del(asg['target_group_ar_ns'])
|
||||
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']]
|
||||
try:
|
||||
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']]
|
||||
except ClientError as e:
|
||||
if e.response['Error']['Code'] == 'TargetGroupNotFound':
|
||||
asg['target_group_names'] = []
|
||||
else:
|
||||
asg['target_group_names'] = []
|
||||
matched_asgs.append(asg)
|
||||
|
||||
Reference in New Issue
Block a user