def lambda_handler()

in source/solution-helper.py [0:0]


def lambda_handler(event, context):
    log.info('Received event: {}'.format(json.dumps(event)))
    response_data = {
        "Message": "No action is needed."
    }
    properties = event['ResourceProperties']

    try:
        if event['RequestType'] in ['Create', 'Update']:
            response_data = {
                "UUID": str(uuid.uuid4())
            }

        if event['ResourceType'] == 'Custom::SendAnonymousMetrics' and properties['SendAnonymousMetrics'] == 'Yes':
            solution_id = properties['SolutionId']
            solution_version = properties['SolutionVersion']
            solution_uuid = properties['SolutionUuid']
            region = properties['Region']
            event_type = properties['EventType']
            send_anonymous_metric(solution_id, solution_version, solution_uuid, region, event_type, event['RequestType'])
            response_data = {
                "Message": "Sent anonymous metric"
            }

        send_response(event, context, 'SUCCESS', response_data)
    except Exception as e:
        log.error('Error: {}'.format(e))
        response_data = {
            'Error': e
        }
        send_response(event, context, 'FAILED', response_data)