I think I have it:
<?php
require dirname(__DIR__) . '/config/requirements.php';
require dirname(__DIR__) . '/vendor/autoload.php';
use App\Application;
use Cake\Cache\Cache;
use Cake\Log\Log;
function lambdatest($data) {
$app = new Application(dirname(__DIR__) . '/config');
$app->bootstrap();
$app->pluginBootstrap();
Cache::disable();
Log::drop("debug");
Log::drop("error");
Log::drop("sqllog");
return \Cake\ORM\TableRegistry::getTableLocator()->get("Users")->find()->count();
}
I had to disable all loggers, because I get the same errors than with commands (Could not load class debug).