brefphp / bref

Serverless PHP on AWS Lambda
https://bref.sh
MIT License
3.05k stars 364 forks source link

Can I fire putJobSuccessResult event from AWS Lambda which is developed with Bref? #1781

Closed tentree-development closed 2 months ago

tentree-development commented 2 months ago

I am setting up aws codepipeline and need to fire putJobSuccessFresult so pipeline can finish the deployment task. Currently I can't call this event so it hangs and times out eventually. Here is the error message I am getting. From my understanding I won't be able to push my code using codepipeline?

"errorType": "Bref\Event\InvalidLambdaEvent", "errorMessage": "This handler expected to be invoked with a API Gateway or ALB event. Instead, the handler was invoked with invalid event data: Array\n(\n [CodePipeline.job] => Array\n (\n "#0 /var/task/vendor/bref/bref/src/Event/Http/HttpHandler.php(23): Bref\Event\Http\HttpRequestEvent->__construct()", "#1 /var/task/vendor/bref/bref/src/Runtime/Invoker.php(29): Bref\Event\Http\HttpHandler->handle()", "#2 /var/task/vendor/bref/bref/src/Runtime/LambdaRuntime.php(91): Bref\Runtime\Invoker->invoke()", "#3 /opt/bootstrap(43): Bref\Runtime\LambdaRuntime->processNextEvent()", "#4 {main}`

=========serverless.yml========= service: app

provider: name: aws region: us-west-2

plugins:

functions: api: handler: public/index.php description: '' runtime: php-83-fpm timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds) events:

Exclude files from deployment

package: patterns:

=========index.php========= <?php

use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Factory\AppFactory;

require DIR . '/../vendor/autoload.php';

/**

/**

/**

// Define app routes $app->get('/', function (Request $request, Response $response, $args) { $response->getBody()->write("Welcome to the location serverless app!"); return $response; });

$app->get('/phpinfo', function (Request $request, Response $response, $args) { phpinfo(); });

return function ($event) { return 'Hello ' . ($event['name'] ?? 'world'); };

// Run app $app->run();

mnapoli commented 2 months ago

How is this a bug? Can you open a support discussion instead?