Skip to content

Commit

Permalink
Merge pull request #20 from SPHTech-Platform/fix/ext-id-logic
Browse files Browse the repository at this point in the history
change the python output to check the status
  • Loading branch information
uchinda-sph authored Feb 28, 2023
2 parents 0ddf98d + 8729ade commit 072adc2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ resource "aws_lambda_invocation" "external_id" {
})

depends_on = [
module.lambda,
aws_secretsmanager_secret_version.aqua_cspm_secret,
]
}
Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "onboarding_data" {
description = "Details of the onboarding"
value = jsondecode(aws_lambda_invocation.onboarding.result)["data"]
value = jsondecode(aws_lambda_invocation.onboarding.result)
}
8 changes: 3 additions & 5 deletions src/lambda_function/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def lambda_handler(event, ctxt):
for i in range(max_attempts):
try:
extid = get_ext_id(aqua_url, aqua_api_key, aqua_secret)
resData = {'ExternalId': extid}
return resData
sucExtID = {'status': 'SUCCESS', 'ExternalId': extid}
return sucExtID
except Exception as e:
LOGGER.error(e)
if i == max_attempts - 1:
Expand All @@ -48,13 +48,11 @@ def lambda_handler(event, ctxt):
group = rp['Group']
role_arn = rp['RoleArn']
acc = rp['AccId']
onbData = {}
try:
g_id = get_gid(aqua_url, aqua_api_key, aqua_secret, group)
register(aqua_url, aqua_api_key, aqua_secret, acc, role_arn, extid, g_id)
LOGGER.info(f'Account registered {acc}')
onbData = {'AccountId': acc, 'Registered': True}
sucMsg = {'status': 'SUCCESS', 'data': onbData}
sucMsg = {'status': 'SUCCESS', 'AccountId': acc, 'Registered': True}
return sucMsg
except Exception as e:
LOGGER.error(e)
Expand Down
Binary file modified src/lambda_function/lambda_function.zip
Binary file not shown.

0 comments on commit 072adc2

Please sign in to comment.