in assets/lambda/code/initialize_defs_cr/lambda.py [0:0]
def lambda_handler(event, context):
"""Custom Resource to populate initial Virus definitions"""
event_type = event["RequestType"]
if event_type == "Create":
try:
fn_name = event["ResourceProperties"]["FnName"]
result = lambda_client.invoke(FunctionName=fn_name)
error = result.get("FunctionError")
if not error:
reason = "Initial definition download succeeded"
logger.info(reason)
return send(event, context, SUCCESS, {}, reason=reason)
else:
reason = f"Initial definition download failed: {error}"
logger.error(reason)
return send(event, context, FAILED, {}, reason=reason)
except botocore.exceptions.ClientError as e:
logger.error(e)
return send(event, context, FAILED, {}, reason=e)
else:
reason = f"Nothing to do on {event_type}"
logger.info(reason)
return send(event, context, SUCCESS, {}, reason=reason)