in core/src/emr-eks-platform/resources/lambdas/managed-endpoint/lambda.py [0:0]
def is_complete(event, ctx):
log.info(event)
requestType = '_DELETE' if event['RequestType'] == 'Delete' else '_CREATEUPDATE'
log.info(requestType)
endpoint_id = event['PhysicalResourceId']
response = emrcontainers.describe_managed_endpoint(
id=endpoint_id,
virtualClusterId=event['ResourceProperties']['clusterId']
)
log.info(response)
log.info(response['endpoint'])
if (response['endpoint'] == None):
return json.dumps({"IsComplete": False})
log.info("current endpoint " + endpoint_id)
state = response['endpoint']['state'] + requestType
log.info(state)
response['endpoint']['createdAt'] = ""
log.info(response['endpoint']['createdAt'])
if state == "ACTIVE_CREATEUPDATE":
##Reducing the data returned to the custom resource
data = {
"securityGroup": response['endpoint']['securityGroup'],
"subnetIds": response['endpoint']['securityGroup'],
"id": response['endpoint']['id'],
"arn": response['endpoint']['arn']
}
log.info({"IsComplete": True, "Data": data})
return {"IsComplete": True, "Data": data}
elif state == "TERMINATED_DELETE":
return {"IsComplete": True}
elif state == "TERMINATED_CREATEUPDATE" or state == "TERMINATED_WITH_ERRORS_CREATEUPDATE" or state == "TERMINATED_WITH_ERRORS_DELETE" or state == "TERMINATING_CREATEUPDATE":
raise Exception('managed endpoint failed.')
else:
return {"IsComplete": False}