Skip to content

Commit

Permalink
update the code to retry
Browse files Browse the repository at this point in the history
  • Loading branch information
uchinda-sph committed Feb 28, 2023
1 parent af38748 commit 313beed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/lambda_function/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ def lambda_handler(event, ctxt):

if event['LogicalResourceId'] == 'ExternalIDInvoke':
LOGGER.info('ExtID creation started :{}'.format(event))
try:
extid = get_ext_id(aqua_url, aqua_api_key, aqua_secret)
resData = {'ExternalId': extid}
return resData
except Exception as e:
LOGGER.error(e)
failExtID = {'status': 'FAILED', 'message': str(e)}
return failExtID
max_attempts = 3
for i in range(max_attempts):
try:
extid = get_ext_id(aqua_url, aqua_api_key, aqua_secret)
resData = {'ExternalId': extid}
return resData
except Exception as e:
LOGGER.error(e)
if i == max_attempts - 1:
failExtID = {'status': 'FAILED', 'message': str(e)}
return failExtID

elif event['LogicalResourceId'] == 'OnboardingInvoke':
LOGGER.info('Onboarding started :{}'.format(event))
Expand Down
Binary file modified src/lambda_function/lambda_function.zip
Binary file not shown.

0 comments on commit 313beed

Please sign in to comment.