[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:
parent
ae5c370737
commit
f0cf1b35d5
1 changed files with 7 additions and 3 deletions
|
@ -370,9 +370,13 @@ def find_asgs(conn, module, name=None, tags=None):
|
||||||
del(asg['target_group_ar_ns'])
|
del(asg['target_group_ar_ns'])
|
||||||
if asg.get('target_group_arns'):
|
if asg.get('target_group_arns'):
|
||||||
if elbv2:
|
if elbv2:
|
||||||
tg_paginator = elbv2.get_paginator('describe_target_groups')
|
try:
|
||||||
tg_result = tg_paginator.paginate(TargetGroupArns=asg['target_group_arns']).build_full_result()
|
tg_paginator = elbv2.get_paginator('describe_target_groups')
|
||||||
asg['target_group_names'] = [tg['TargetGroupName'] for tg in tg_result['TargetGroups']]
|
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:
|
else:
|
||||||
asg['target_group_names'] = []
|
asg['target_group_names'] = []
|
||||||
matched_asgs.append(asg)
|
matched_asgs.append(asg)
|
||||||
|
|
Loading…
Reference in a new issue