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:
./vendor/bref/bref
functions:
api:
handler: public/index.php
description: ''
runtime: php-83-fpm
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
events:
httpApi: '*'
Exclude files from deployment
package:
patterns:
'!node_modules/**'
'!tests/**'
=========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';
/**
Instantiate App
In order for the factory to work you need to ensure you have installed
a supported PSR-7 implementation of your choice e.g.: Slim PSR-7 and a supported
ServerRequest creator (included with Slim PSR-7)
*/
$app = AppFactory::create();
/**
The routing middleware should be added earlier than the ErrorMiddleware
Otherwise exceptions thrown from it will not be handled by the middleware
*/
$app->addRoutingMiddleware();
/**
Add Error Middleware
@param bool $displayErrorDetails -> Should be set to false in production
@param bool $logErrors -> Parameter is passed to the default ErrorHandler
@param bool $logErrorDetails -> Display error details in error log
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();