def lambda_handler()

in lambda/lambda_function_write.py [0:0]


def lambda_handler(event, context):
  # load the side-loaded Amazon Location Service model; needed during Public Preview
  os.environ["AWS_DATA_PATH"] = os.environ["LAMBDA_TASK_ROOT"]

  print(event)

  updates = [
    {
      "DeviceId": event["deviceid"],
      "SampleTime": datetime.fromtimestamp(event["timestamp"]).isoformat(),
      "Position": [
        event["lon"],
        event["lat"]
      ]
    }
  ]
  
  print(updates)

  client = boto3.client("location")
  response = client.batch_update_device_position(TrackerName=TRACKER_NAME, Updates=updates)
  
  return {
    "statusCode": 200,
    "body": json.dumps(response)
  }