@@ -25,17 +25,22 @@ def lambda_handler(event, ctxt):
25
25
aqua_secret = conf ['aqua_secret' ]
26
26
except Exception as e :
27
27
LOGGER .error ('Error retrieving Keys: {e}' )
28
- return json .dumps ({'status' : 'FAILED' , 'message' : 'Error retrieving Keys' })
28
+ failRetKey = {'status' : 'FAILED' , 'message' : 'Error retrieving Keys' }
29
+ return failRetKey
29
30
30
31
if event ['LogicalResourceId' ] == 'ExternalIDInvoke' :
31
32
LOGGER .info ('ExtID creation started :{}' .format (event ))
32
- try :
33
- extid = get_ext_id (aqua_url , aqua_api_key , aqua_secret )
34
- resData = {'ExternalId' : extid }
35
- return resData
36
- except Exception as e :
37
- LOGGER .error (e )
38
- return json .dumps ({'status' : 'FAILED' , 'message' : str (e )})
33
+ max_attempts = 3
34
+ for i in range (max_attempts ):
35
+ try :
36
+ extid = get_ext_id (aqua_url , aqua_api_key , aqua_secret )
37
+ resData = {'ExternalId' : extid }
38
+ return resData
39
+ except Exception as e :
40
+ LOGGER .error (e )
41
+ if i == max_attempts - 1 :
42
+ failExtID = {'status' : 'FAILED' , 'message' : str (e )}
43
+ return failExtID
39
44
40
45
elif event ['LogicalResourceId' ] == 'OnboardingInvoke' :
41
46
LOGGER .info ('Onboarding started :{}' .format (event ))
@@ -49,10 +54,12 @@ def lambda_handler(event, ctxt):
49
54
register (aqua_url , aqua_api_key , aqua_secret , acc , role_arn , extid , g_id )
50
55
LOGGER .info (f'Account registered { acc } ' )
51
56
onbData = {'AccountId' : acc , 'Registered' : True }
52
- return json .dumps ({'status' : 'SUCCESS' , 'data' : onbData })
57
+ sucMsg = {'status' : 'SUCCESS' , 'data' : onbData }
58
+ return sucMsg
53
59
except Exception as e :
54
60
LOGGER .error (e )
55
- return json .dumps ({'status' : 'FAILED' , 'message' : str (e )})
61
+ errMsg = {'status' : 'FAILED' , 'message' : str (e )}
62
+ return errMsg
56
63
57
64
58
65
def get_conf (secret ):
0 commit comments