brefphp / laravel-bridge Goto Github PK
View Code? Open in Web Editor NEWPackage to use Laravel on AWS Lambda with Bref
Home Page: https://bref.sh/docs/frameworks/laravel.html
License: MIT License
Package to use Laravel on AWS Lambda with Bref
Home Page: https://bref.sh/docs/frameworks/laravel.html
License: MIT License
Is there any way to find out how often a job already failed, inside the job?
For example: If I configure the queue like in the example with maxReceiveCount: 3
, I would like to know if the current execution is the first or the last job execution.
Especially knowing if it is the last execution is important, because I would like to send a notification to the developers only the last time.
The failed
function inside of a job would be perfect for that, but as far as I understand this does not work with this package.
Is there any solution to this problem or am I missing something?
i trying bref using laravel mix for assets but i got error like this. what happend?
Deploying laravel to stage dev (us-east-1)
× Stack laravel-dev failed to deploy (426s)
Environment: win32, node 16.14.0, framework 3.3.0 (local) 3.4.0v (global), plugin 6.1.0, SDK 4.3.1
Credentials: Local, "default" profile
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
CREATE_FAILED: websiteCDN060D946D (AWS::CloudFront::Distribution)
Resource handler returned message: "Access denied for operation 'Your account must be verified before you can add new CloudFront resources. To verify your account, please contact AWS Support (https://console.aws.amazon.com/support/home#/) and include this error message. (Service: CloudFront, Status Code: 403, Request ID: a550e902-1439-4b41-ac88-xxx, Extended Request ID: null)'." (RequestToken: ef02649a-8aa7-81e5-5140-xxx, HandlerErrorCode: AccessDenied)
View the full error: https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aus-east-1%3A298724920849%3Astack%2Flaravel-dev%2F42e21f90-96e7-11ec-8f3b-xxx
I'm trying to use this project in a containerized fashion with Lambda (there's not a lot of docs for using Docker). I've been through the docs here and through Bref and am unsure what I'm missing/doing wrong. When processing lobs locally and within AWS I get the error:
{
"errorMessage": "RequestId: 36907a63-97ff-478b-b1fd-630f060a8661 Error: Runtime exited without providing a reason",
"errorType": "Runtime.ExitError"
}
Locally I'm able to use serverless invoke -f worker --file=sqs-queue-event.json
to tell my local env to process the job. However both locally and in AWS that's the only feedback I get, with no errors or anything on the Laravel side. It just doesn't work 🤷 . Logs are configured to go to stderr locally and bugsnag/stderr in Lambda.
My Dockerfile
:
FROM bref/php-80
ADD . /var/task
# production-ready dependencies
RUN curl -s https://getcomposer.org/installer | php \
&& php composer.phar install --no-interaction --optimize-autoloader --no-dev --prefer-dist --no-cache \
&& rm composer.phar
ENTRYPOINT ["php", "worker.php"]
My container is defined within the serverless architecture as:
functions:
worker:
reservedConcurrency: 10
image: xxxxx.xxxxx.amazonaws.com/[project]:lambda-serverless
events:
# Declares that our worker is triggered by jobs in SQS
- sqs:
arn: !GetAtt SendMessagesQueue.Arn
# If you create the queue manually, the line above could be:
# arn: 'arn:aws:sqs:us-east-1:1234567890:my_sqs_queue'
# Only 1 item at a time to simplify error handling
batchSize: 1
If anyone had this error then I found a solution for it. I hope I helped someone with this.
You need to update the .serverless file with this code:
package:
individually: true
excludeDevDependencies: false
I'm just getting started using bref and the laravel-bridge and ran into an issue when requiring the dependencies.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- aws/aws-sdk-php[3.134.0, ..., 3.173.19] require guzzlehttp/psr7 ^1.4.1 -> found guzzlehttp/psr7[1.4.1, ..., 1.x-dev] but the package is fixed to 2.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- aws/aws-sdk-php[3.173.20, ..., 3.185.18] require guzzlehttp/psr7 ^1.7.0 -> found guzzlehttp/psr7[1.7.0, ..., 1.x-dev] but the package is fixed to 2.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- bref/laravel-bridge 1.1.0 requires aws/aws-sdk-php ^3.134 -> satisfiable by aws/aws-sdk-php[3.134.0, ..., 3.185.18].
- Root composer.json requires bref/laravel-bridge ^1.1 -> satisfiable by bref/laravel-bridge[1.1.0].
# Install a fresh version of Laravel
curl -s "https://laravel.build/laravel-bref-testing?with=mysql,redis" | bash
cd laravel-bref-testing
# Publish the Sail assets, not required but I did it.
php artisan sail:publish
# Build the app container
sail build --no-cache
# Start the stack
sail up -d
# Install bref/bref and bref/laravel-bridge
sail composer require bref/bref bref/laravel-bridge
Any help would be greatly appreciated, thanks!
Hi
I have a case where the trusted proxies should allow all ($proxies = '*';
).
It seems that the package overwrites the config that's been set in the TrustProxies
middleware.
My solution now is to overwrite the config again in the AppServiceProvider
. Is this the preferred way?
Shouldn't it be better to provide a config/serverless.php
configuration file, and make that behaviour configurable?
I have just discovered the BREF package (via Serverless Chats Podcast) and I am very interested in trying it out. One of my pain points in my AWS deployment is my queue workers. I would love to move those to Lambda.
The application currently uses Laravel Horizon. I am not familiar enough with the underpinnings of horizon to apply the given documentation to a Horizon context. An example, or some documentation on converting Horizon to use this package would be a welcome addition.
Using Laravel 7 and the php 7.4 layer.
I have setup a worker.php and made the changes to the serverless.yml file. I am able to write to the SQS queue, but when the lambda tries to process the event, I am seeing this error message:
This handler expected to be invoked with a API Gateway or ALB event. Instead, the handler was invoked with invalid event data.
"stack": [
"#0 /var/task/vendor/bref/bref/src/Event/Http/HttpHandler.php(20): Bref\Event\Http\HttpRequestEvent->__construct()",
"#1 /var/task/vendor/bref/bref/src/Runtime/LambdaRuntime.php(107): Bref\Event\Http\HttpHandler->handle()",
"#2 /opt/bootstrap(35): Bref\Runtime\LambdaRuntime->processNextEvent()",
"#3 {main}"
]
It seems to me that the API handler is trying to process the event, not the SQS handler.
Hi Everyone!
I am trying to use this package to configure my application in serverless, and I found a deprecated setting that comes with the default Laravel serverless.yml
template.
serverless.yml
:
Deprecated setting:
Following the serverless upgrade documentation we can use the 20200924
instead.
https://www.serverless.com/framework/docs/guides/upgrading-v3#lambda-hashing-algorithm
First of all: very nice work 👏 Love the possibility to go serverless with a Laravel project, and so far everything works except for jobs processing.
I setup everything with a CDK project, so I hope I am not missing something. But here is my setup:
The queue Lambda config looks like this:
this.worker = new lambda.Function(scope, 'WorkerHandler', {
runtime: lambda.Runtime.PROVIDED_AL2,
handler: 'worker.php',
layers: [
lambda.LayerVersion.fromLayerVersionArn(
scope,
'BrefPHPWorkerLayer',
'arn:aws:lambda:eu-central-1:209497400698:layer:php-81:16'
),
lambda.LayerVersion.fromLayerVersionArn(
scope,
'ConsoleLayer',
'arn:aws:lambda:eu-central-1:209497400698:layer:console:55'
),
],
code: codeBundle,
memorySize: 512,
environment,
timeout: cdk.Duration.minutes(2),
})
The job that I trigger simply does
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
Log::info('IT WORKED!');
}
In the worker.php
I placed a log which just logs Log::info('WORKER STARTED!');
. I also went ahead and put a log in the LaravelSqsHandler
within the handleSqs
method, before the foreach
loop
Now, when a message lands in the queue, it definitely get's handled, this is what I see in the logs:
Where I expected to also see IT WORKED!
. What am I missing here? Thank you for a hint.
Hey folks, thanks for putting together such an extensive project with brefphp
, it's really paved the way for using Lambda. I'm building a prototype with Lambda to try to understand it further. I've built a docker container for my app with the following...
FROM bref/php-80
ADD . /var/task
# production-ready dependencies
RUN curl -s https://getcomposer.org/installer | php \
&& php composer.phar install --no-interaction --optimize-autoloader --no-dev --prefer-dist --no-cache \
&& rm composer.phar
ENTRYPOINT ["php", "worker.php"]
I wanted to put the Dockerfile here in case it's useful to other folks who are trying to use lambda in a containerized fashion. For what it's worth, I haven't gotten this actually working yet, though in CloudWatch I'm not seeing any errors. I've reached my time box on when I'm able to investigate this exploration, I hope to continue another time!
Hi! Is it possible to have several SQS queues and connections and map them to different lamda instances using bref?
For example, I have regular queue tasks that can be processed on 1gb lambda instance, and a cpu intensive tasks that requires a 5-10gb lamda instance. Currently I have several servers and map tasks between them using different ‘artisan queue:work —connection={name}’ workers.
Is it something that bref/serverless can handle?
I've got a barebones Laravel 8 project, setup per instructions at https://bref.sh/docs/frameworks/laravel.html. (The only difference is I'm using HTTP API).
When I deploy from my local machine the default welcome view renders without issue. When I deploy via CI I get this error with the welcome view: There is no existing directory at "/var/task/storage/logs" and it could not be created: Read-only file system
.
I don't believe there is any issue with the serverless portion of this as comparing the debug output (with SLS_DEPLOY=1) didn't show many differences.
I compared the output of my .serverless/project.zip
that was created on my machine vs in CI and the only noticeable differences I saw was my CI version was missing:
bootstrap/cache/packages.php
bootstrap/cache/services.php
My ci config is as such:
curl -sS https://getcomposer.org/installer | php
php composer.phar install --no-dev --no-progress --prefer-dist
serverless deploy -v -s staging
Any thoughts on what I might be doing wrong?
Hi,
I usually have more than 30k messages in the queue per day and the time to process each message can take some minutes...
It seems the "Messages in Flight" floats between 50-70 per time. is it possible to consume more messages at once?
Is there an option to set the Lambda Reserved concurrency?
Thank you
If you have a problem with storage in Lambda, then I believe this solution is for you. Please check your logs and try to find any of these problems if you have this then try to do what is in this issue:
"touch(): Unable to create file", "mkdir()", "No such file or directory"
I used spatie media-library in my project, and I had a problem with storage media in /tmp, but for a long time I found a solution for that.
Solution for that is to install extra-php-extensions and update config file
After that, you should update app.php file in bootstrap
Now everything should work fine :)
I'm getting the below issue with the latest laravel and laravel-bridge latest.
Error executing "SendMessage" on "https://sqs.ap-southeast-1.amazonaws.com/{id}/testing-queue"; AWS HTTP error: Client error: `POST https://sqs.ap-southeast-1.amazonaws.com/{id}/testing-queue` resulted in a `403 Forbidden` response:
<?xml version="1.0"?><ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><Error><Type>Sender</Type><Code>I (truncated...)
InvalidClientTokenId (client): The security token included in the request is invalid. - <?xml version="1.0"?><ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><Error><Type>Sender</Type><Code>InvalidClientTokenId</Code><Message>The security token included in the request is invalid.</Message><Detail/></Error><RequestId>{request_id}</RequestId></ErrorResponse>
Anyone having issue like me?
My IAM has full administrator access and my testing repo looks exactly like the https://github.com/brefphp/examples/tree/master/Laravel/queues except mine is using the latest laravel and bref latest.
Thanks
I am currently using ElastiCache with redis as the driver for the queues.
Based on your example posted at https://github.com/brefphp/examples/blob/master/Laravel/queues/worker.php I see that only one LaravelSqsHandler class is available, I am wondering if it is possible to process the jobs using LaravelRedisHandler or something like that.
Hello,
I'm wondering what would be the best approach to the following scenario:
I have a VPS for the site and Mysql and I want to offload the retrieval and processing to AWS Lambda but I don't think the lambda can perform the database queries. What are my options here? The best I could come up so far is this using webhooks:
Are there better options?
Thank you.
I'm running Laravel 8, Bref 1.3 and Laravel-Bridge 1.1
When I run serverless deploy
I got this error:
Cannot parse "serverless.yml": unknown tag !<!node_modules/**> in "/Users/aws/Desktop/laravel-aws-lambda/serverless.yml" (16:9)
13 | # Directories to exclude from deplo ...
14 | patterns:
15 | - !node_modules/**
16 | - !public/storage
--------------^
17 | - !resources/assets/**
18 | - !storage/**
Does anybody face this problem?
Hi, I'm using an S3 bucket to save files from Laravel application uploads. When trying to upload the file, I get the following error:
[previous exception] [object] (GuzzleHttp\\Exception\\ClientException(code: 403): Client error: `PUT https://my-bucket.s3.amazonaws.com/1077c090.png` resulted in a `403 Forbidden ` response:
<Error><Code>InvalidAccessKeyId</Code><Message>The AWS Access Key Id you provided does not exist in our records.</Message><AWSAccessKeyId>ASIAZ7N74ORBT6RJ5AAA</AWSAccessKeyId><RequestId>KFZADDG3V6QX8AAA</RequestId><HostId >IH1lvnySucUhfJBX7k2HAAA=</HostId></Error> {"userId":2,"exception":"[object] (Aws\\S3\\Exception\\S3Exception(code: 0): Error executing \"PutObject\" on \"https://my-bucket.s3.amazonaws.com/1077c090.png\"; AWS HTTP error: Client error: `PUT https://my-bucket.s3.amazonaws.com/1077c090.png` resulted in a `403 Forbidden` response:
The problem in this case is that the second error says that the access key is invalid. I don't know where he gets this key from, it's not the key I inform in the .env
file.
What is this key that it displays in the error: <AWSAccessKeyId>ASIAZ7N74ORBT6RJ5AAA</AWSAccessKeyId>
?
(not the original key that displays on panel, omitted characters).
Any idea what it could be?
Thanks
file_put_contents(/var/task/storage/framework/cache/facade-d6c8a1ed6fde286ae195e535517be856b15c1f39.php): failed to open stream: No such file or directory
What would be the best way to use laravel to write event driven function?
Like, a trigger from an S3 or something?!
Thanks
As per laravel docs, every application should create encrypted XSRF-TOKEN
cookie. I also have this cookie on my dev environment but not on lambda function.
This is the cookie missing on lambda function.
I've tried adding custom header for lambda function in serverless file, like:
functions:
# This function runs the my website/API
web:
handler: public/index.php
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
layers:
- ${bref:layer.php-74-fpm}
- ${bref:extra.gd-php-74}
events:
- httpApi: '*'
cors:
origin: '*'
headers:
- X-XSRF-TOKEN
I use this to on the frontend(Inertia) application for axios
requests.
Does someone has any idea if I'm missing something?
Any plans to upgrade the dependencies to support Laravel 8 anytime soon?
Hey! I'm having an issue when using the package because of line 46 of BrefServiceProvider:
// We change Laravel's default log destination to stderr
$logDriver = Config::get('logging.default');
if ($logDriver === 'stack') {
Config::set('logging.default', 'stderr');
}
We're using multi-channel logging, and our stack channel already include stderr. Config bellow:
'stack' => [
'driver' => 'stack',
'channels' => ['stderr', 'bugsnag'],
'ignore_exceptions' => false,
],
When using the package the bugsnag just stop working.
Couldn't we just leave this to user or at least change approach to just ensure stack contains stderr instead of changing logging.default (like below example)?
// We change Laravel's default log destination to stderr
$logDriver = Config::get('logging.default');
if ($logDriver === 'stack') {
$channels = Config::get('logging.channels.stack.channels', []);
array_push($channels, 'stderr');
Config::set('logging.channels.stack.channels', array_unique($channels));
}
Hello everybody.
I'm trying to deploy a laravel application with aws lambda. But I get this error SQLSTATE[HY000] [2002] Connection refused
can someone guide me please
Hello,
I wanted to know if anyone has experienced missing invocations of some of their console commands? I have an EventBridge setup to run each minute, invoking my artisan
Lambda, running schedule:run
... this is working for the vast majority of jobs.
There are some commands that seem to never get run (even though they work fine using the sls invoke -f artisan --stage prod --data "artisan:command"
).
Here is an example of a job that should be called hourly - you can see some random gaps.
I have checked other jobs that are more frequent, and they seem to be running on schedule (every 2 minutes) without gaps... and I have another job that is scheduled daily()
that never gets invoked.
I have changed the EventBridge to use the cron(* * * * ? *)
rule instead of the rate(1 minute)
.
Any help would be appreciated - thanks!
Hi,
When debugging the filesystems settings, I see that the token was not added as described in the documentation: https://bref.sh/docs/frameworks/laravel.html#file-storage-on-s3
That's it! The 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY' and 'AWS_SESSION_TOKEN' variables are defined automatically on AWS Lambda, you don't have to define them.
The result of Laravel's dd command returns the configuration array as below without TOKEN.
"s3" => array:9 [
"driver" => "s3"
"key" => "ASIAZ7N74ORB26CAAAAA"
"secret" => "EC3K2NFgsij3oUHYo7HDqAd21+iYoQ6BWNRAAAAA"
"token" => null
"region" => "us-east-1"
"bucket" => "my-bucket"
"url" => null
"endpoint" => null
"root" => "/my-path"
]
Any idea what it could be?
Thanks
Hey guys,
First time setting up the Laravel Bridge to work with SQS and hoping you can shed some insight into why I cannot get it working.
I have deployed my Laravel application to Lambda, and it has created the jobsWorker Lambda Function as well as the SQS Queue and DQL. I am able to push jobs to the queue and I can see they are inflight, however after a few attempts it gets sent to the DLQ.
Inside my Job I have a message that gets captured to Sentry so I can see it's run for debugging purposes, however the Job doesn't seem to be getting ran.
I have added the construct to the Serverless.yml file:
constructs:
jobs:
type: queue
worker:
handler: worker.php
layers:
- ${bref:layer.php-81}
This is my worker file:
<?php declare(strict_types=1);
use Bref\LaravelBridge\Queue\LaravelSqsHandler;
use Illuminate\Foundation\Application;
require __DIR__ . '/vendor/autoload.php';
/** @var Application $app */
$app = require __DIR__ . '/bootstrap/app.php';
/**
* For Lumen, use:
* $app->make(Laravel\Lumen\Console\Kernel::class);
* $app->boot();
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();
return $app->makeWith(LaravelSqsHandler::class, [
'connection' => 'sqs', // this is the Laravel Queue connection
'queue' => getenv('SQS_QUEUE'),
]);
Any help would be appreciated!
-- EDIT --
I have added a Log::debug() inside the worker.php and can see in Cloudwatch that it is being triggered.
Within the logs for the jobsWorker I can also see the following message:
Task timed out after 6.01 seconds
I am using laravel 5.8 and getting this error while composer require .
Using version ^0.5.32 for bref/bref
Using version ^0.2.3 for bref/laravel-bridge
./composer.json has been updated
Running composer update bref/bref bref/laravel-bridge
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- illuminate/queue[v6.0.0, ..., 6.x-dev] require illuminate/console ^6.0 -> found illuminate/console[v6.0.0, ..., 6.x-dev] but it conflicts with another require.
- illuminate/queue[v7.0.0, ..., 7.x-dev] require illuminate/console ^7.0 -> found illuminate/console[v7.0.0, ..., 7.x-dev] but it conflicts with another require.
- illuminate/queue[v8.0.0, ..., 8.x-dev] require illuminate/console ^8.0 -> found illuminate/console[v8.0.0, ..., 8.x-dev] but it conflicts with another require.
- bref/laravel-bridge 0.2.3 requires illuminate/queue ^6.0|^7.0|^8.0 -> satisfiable by illuminate/queue[v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev].
- Root composer.json requires bref/laravel-bridge ^0.2.3 -> satisfiable by bref/laravel-bridge[0.2.3].
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
How to resolve this?
Hi,
Just wondering if this package will be compatible with Laravel 9?
Thank you
Hi,
I create a test app for this package on https://github.com/otezz/test-bref-queue. I can see jobs from laravel are processed and record inserted to RDS successfully, but it seems that the job not quitting immediately and idling until the lambda function time out causing the task marked as failed.
Is there something wrong with my configurations?
serverless.yml
...
worker:
handler: worker.php
timeout: 900
layers:
- ${bref:layer.php-81}
events:
- sqs:
arn: !GetAtt GPT3Queue.Arn
batchSize: 3
...
Worker.php
<?php declare(strict_types=1);
use Bref\LaravelBridge\Queue\LaravelSqsHandler;
use Illuminate\Foundation\Application;
require __DIR__ . '/vendor/autoload.php';
/** @var Application $app */
$app = require __DIR__ . '/bootstrap/app.php';
/**
* For Lumen, use:
* $app->make(Laravel\Lumen\Console\Kernel::class);
* $app->boot();
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();
return $app->makeWith(LaravelSqsHandler::class, [
'connection' => 'sqs', // this is the Laravel Queue connection
'queue' => getenv('SQS_QUEUE'),
]);
Inside the queues, it seems I don't have access to the lambda context. $_SERVER['LAMBDA_INVOCATION_CONTEXT']
is missing. Am I doing something wrong?
Hi, it would be nice to update the bref dependency to support version ^1.0
.
Problem 1
- bref/laravel-bridge 0.2.3 requires bref/bref ~0.5.20 -> satisfiable by bref/bref[0.5.20, 0.5.21, 0.5.22, 0.5.23, 0.5.24, 0.5.25, 0.5.26, 0.5.27, 0.5.28, 0.5.29, 0.5.30, 0.5.31, 0.5.32, 0.5.33, 0.5.x-dev] but these conflict with your requirements or minimum-stability.
- bref/laravel-bridge 0.2.3 requires bref/bref ~0.5.20 -> satisfiable by bref/bref[0.5.20, 0.5.21, 0.5.22, 0.5.23, 0.5.24, 0.5.25, 0.5.26, 0.5.27, 0.5.28, 0.5.29, 0.5.30, 0.5.31, 0.5.32, 0.5.33, 0.5.x-dev] but these conflict with your requirements or minimum-stability.
- Installation request for bref/laravel-bridge ^0.2.3 -> satisfiable by bref/laravel-bridge[0.2.3].```
I noticed this repository has a package-like style and I was wondering if you're thinking about providing a package that makes it easy to use Bref on Laravel context.
I would be willing to provide with a Pull Request that brings 2 components to this repository: Bref Facade and Lambda Queue Job and Worker.
You can find the code for these here: https://github.com/deleugpn/laravel-lambda/tree/master/app/Components
The relevance of the Bref Facade is to hide the lambda()
helper behind an interface that can be swapped using the Laravel IoC container in order to help writing test code. Laravel developers are used to having a toolbox of test suite easy to use and swap implementations when needed.
The Lambda Worker is an extension of the artisan command queue:work
that will fetch events from the lambda()
helper (using the facade), build a Laravel job class and send it over to the Worker
to work it out.
Another thing I can suggest keeping in this repository would be a version of the artisan
file that uses an environment variable to decide which command is being issued: https://github.com/deleugpn/laravel-lambda/blob/master/artisan#L39
The motivation for changing the artisan can be found here: brefphp/bref#118 (comment)
Hello
I keep getting this.
"#0 /var/task/vendor/illuminate/database/Eloquent/Model.php(1223): Illuminate\Database\Eloquent\Model::resolveConnection(NULL)",
"#1 /var/task/vendor/illuminate/database/Eloquent/Model.php(1052): Illuminate\Database\Eloquent\Model->getConnection()",
"#2 /var/task/vendor/illuminate/database/Eloquent/Model.php(969): Illuminate\Database\Eloquent\Model->newBaseQueryBuilder()",
"#3 /var/task/vendor/illuminate/database/Eloquent/Model.php(1005): Illuminate\Database\Eloquent\Model->newModelQuery()",
"#4 /var/task/vendor/illuminate/database/Eloquent/Model.php(958): Illuminate\Database\Eloquent\Model->newQueryWithoutScopes()",
"#5 /var/task/vendor/illuminate/database/Eloquent/Model.php(1622): Illuminate\Database\Eloquent\Model->newQuery()",
"#6 /var/task/vendor/illuminate/database/Eloquent/Model.php(1634): Illuminate\Database\Eloquent\Model->__call('create', Array)",
Interesting when the request comes from web the connection to the db has no issues regular bref. But while doing it with lambda I get this error. I did added the security groups as defined on https://bref.sh/docs/environment/database.html
I had to remove this like from the worker in order for it to work.
//$kernel->bootstrap();
Could this be also because this is a lumen project not a full laravel version?
maybe something is not loading?
boostrap/cache
directory has routes.php
(along with packages.php
and services.php
), the deployed lambda function failed because the route cache has an invalid format.boostrap/cache
directory has packages.php
and services.php
, the deployed lambda function failed because the cache directory is absent or isn't present.routes.php
from a deployment package?packages.php
and services.php
?packages.php
and services.php
to Lambda? (In other words, do those caches not depned on an environment where they were generated?)bref:layer.php-73
bootstrap/cache
has routes.cache
START RequestId: ****-****-****-****-**** Version: $LATEST
Erroneous data format for unserializing 'Symfony\Component\Routing\CompiledRoute'
END RequestId: ****-****-****-****-****
REPORT RequestId: ****-****-****-****-**** Duration: 102.57 ms Billed Duration: 103 ms Memory Size: 512 MB Max Memory Used: 17 MB
Unknown application error occurred
bootstrap/cache
is emptyThe /var/task/bootstrap/cache directory must be present and writable.
START RequestId: ****-****-****-****-**** Version: $LATEST
The /var/task/bootstrap/cache directory must be present and writable.
END RequestId: ****-****-****-****-****
REPORT RequestId: ****-****-****-****-**** Duration: 100.26 ms Billed Duration: 101 ms Memory Size: 512 MB Max Memory Used: 14 MB
Unknown application error occurred
Using this package allows sqs as event triggers for lambda.
Im wondering if there are any side effects if we use it for FIFO queue?
ty
I setup an app and am working with passport.
when going to the url
it sends me to the login screen, once i login it redirects me to
with body {"message":"Forbidden"}
i have Illuminate\Support\Facades\URL::forceRootUrl(env('APP_URL')); in the boot() function of app/Providers/AppServiceProvider.php so im unsure why its forwarding to the api-gateway url.
when i return to https://dev-patient-api.docsink.com/oauth/authorize?client_id=1301073282&redirect_uri=https://dev-biosense.bots.docsink.com/callback&response_type=code it forwards me to the right place because im already logged in.
Any ideas what i need to do to fix the incorrect redirect?
Thanks a ton for putting this repo out there. Can't wait to use it!
Using Laravel 7/latest.
I am not having any trouble inserting queued jobs, but the worker lambda function gets an error trying to use DeleteMessage. Looks like the prefix or account number is missing. I followed your handler.php script exactly. Feels like I'm missing something quite obvious.
EnvVars:
QUEUE_CONNECTION=sqs
SQS_QUEUE=queue-name
SQS_PREFIX=https://sqs.us-east-2.amazonaws.com/##########
Logs:
Invoke Error {"errorType":"Aws\\Sqs\\Exception\\SqsException","errorMessage":"Error executing \"DeleteMessage\" on \"https:\/\/sqs.us-east-2.amazonaws.com\/queue-name\"; AWS HTTP error: Client error: `POST https:\/\/sqs.us-east-2.amazonaws.com\/queue-name` resulted in a `404 Not Found` response:\n<?xml version=\"1.0\"?><ErrorResponse xmlns=\"http:\/\/queue.amazonaws.com\/doc\/2012-11-05\/\"><Error><Type>Sender<\/Type><Code>I (truncated...)\n InvalidAddress (client): The address queue-name is not valid for this endpoint. - <?xml version=\"1.0\"?><ErrorResponse xmlns=\"http:\/\/queue.amazonaws.com\/doc\/2012-11-05\/\"><Error><Type>Sender<\/Type><Code>InvalidAddress<\/Code><Message>The address queue-name is not valid for this endpoint.<\/Message><Detail\/><\/Error><RequestId>f9c8c3e8-7f30-59cb-8e4f-94c22c91574c<\/RequestId><\/ErrorResponse>","stack":["#0 \/var\/task\/vendor\/aws\/aws-sdk-php\/src\/WrappedHttpHandler.php(97): Aws\\WrappedHttpHandler->parseError()","#1 \/var\/task\/vendor\/guzzlehttp\/promises\/src\/Promise.php(203): Aws\\WrappedHttpHandler->Aws\\{closure}()","#2 \/var\/task\/vendor\/guzzlehttp\/promises\/src\/Promise.php(174): GuzzleHttp\\Promise\\Promise::callHandler()","#3 \/var\/task\/vendor\/guzzlehttp\/promises\/src\/RejectedPromise.php(40): GuzzleHttp\\Promise\\Promise::GuzzleHttp\\Promise\\{closure}()","#4 \/var\/task\/vendor\/guzzlehttp\/promises\/src\/TaskQueue.php(47): GuzzleHttp\\Promise\\RejectedPromise::GuzzleHttp\\Promise\\{closure}()","#5 \/var\/task\/vendor\/guzzlehttp\/guzzle\/src\/Handler\/CurlMultiHandler.php(119): GuzzleHttp\\Promise\\TaskQueue->run()","#6 \/var\/task\/vendor\/guzzlehttp\/guzzle\/src\/Handler\/CurlMultiHandler.php(146): GuzzleHttp\\Handler\\CurlMultiHandler->tick()","#7 \/var\/task\/vendor\/guzzlehttp\/promises\/src\/Promise.php(246): GuzzleHttp\\Handler\\CurlMultiHandler->execute()","#8 \/var\/task\/vendor\/guzzlehttp\/promises\/src\/Promise.php(223): GuzzleHttp\\Promise\\Promise->invokeWaitFn()","#9 \/var\/task\/vendor\/guzzlehttp\/promises\/src\/Promise.php(267): GuzzleHttp\\Promise\\Promise->waitIfPending()","#10 \/var\/task\/vendor\/guzzlehttp\/promises\/src\/Promise.php(225): GuzzleHttp\\Promise\\Promise->invokeWaitList()","#11 \/var\/task\/vendor\/guzzlehttp\/promises\/src\/Promise.php(267): GuzzleHttp\\Promise\\Promise->waitIfPending()","#12 \/var\/task\/vendor\/guzzlehttp\/promises\/src\/Promise.php(225): GuzzleHttp\\Promise\\Promise->invokeWaitList()","#13 \/var\/task\/vendor\/guzzlehttp\/promises\/src\/Promise.php(62): GuzzleHttp\\Promise\\Promise->waitIfPending()","#14 \/var\/task\/vendor\/aws\/aws-sdk-php\/src\/AwsClientTrait.php(58): GuzzleHttp\\Promise\\Promise->wait()","#15 \/var\/task\/vendor\/aws\/aws-sdk-php\/src\/AwsClientTrait.php(86): Aws\\AwsClient->execute()","#16 \/var\/task\/vendor\/laravel\/framework\/src\/Illuminate\/Queue\/Jobs\/SqsJob.php(71): Aws\\AwsClient->__call()","#17 \/var\/task\/vendor\/laravel\/framework\/src\/Illuminate\/Queue\/CallQueuedHandler.php(66): Illuminate\\Queue\\Jobs\\SqsJob->delete()","#18 \/var\/task\/vendor\/laravel\/framework\/src\/Illuminate\/Queue\/Jobs\/Job.php(98): Illuminate\\Queue\\CallQueuedHandler->call()","#19 \/var\/task\/vendor\/bref\/laravel-bridge\/src\/Queue\/LaravelSqsHandler.php(87): Illuminate\\Queue\\Jobs\\Job->fire()","#20 \/var\/task\/vendor\/bref\/laravel-bridge\/src\/Queue\/LaravelSqsHandler.php(69): Bref\\LaravelBridge\\Queue\\LaravelSqsHandler->process()","#21 \/var\/task\/vendor\/bref\/bref\/src\/Event\/Sqs\/SqsHandler.php(18): Bref\\LaravelBridge\\Queue\\LaravelSqsHandler->handleSqs()","#22 \/var\/task\/vendor\/bref\/bref\/src\/Runtime\/LambdaRuntime.php(104): Bref\\Event\\Sqs\\SqsHandler->handle()","#23 \/opt\/bref\/bootstrap.php(38): Bref\\Runtime\\LambdaRuntime->processNextEvent()","#24 {main}"]}
When I setup single queue, it works like a charm. But if I want to have multiple queues, since we can only specify one queue url in SQS_QUEUE
I don't know how to setup.
The reason why I want multiple queues in 1 application is that I want to know if a specific job is still processing. To do that I separate queues for each jobs and long polling the status of queue.
I'm trying to deploy this on gitlab cicd but when I did serverless deploy -v
, Job is succeeded but it doesn't deploy.
Can anyone help me?
Hello! I'm trying to run a tinker command on laravel bref application.
Command:
vendor/bin/bref cli --profile aws-profile laravel-bref-production-artisan -- tinker --execute="dump(config('app'))"
Error message:
START RequestId: 6c4f5dc1-13db-4b1d-822a-edf7bf1b2437 Version: $LATEST
[2022-11-04 21:41:19] production.ERROR: Writing to directory /.config/psysh is not allowed. {"exception":"[object] (ErrorException(code: 0): Writing to directory /.config/psysh is not allowed. at /var/task/vendor/psy/psysh/src/ConfigPaths.php:362)
Does any one have a solution on how to run laravel tinker commands in a bref application? I believe this error is related to psysh trying to write to a history log.
Would you be interested in switching this package to use the relevant async aws packages, like the main brief package. I can help with this. :)
Hi Everyone,
I am trying to configure an API Gateway for my multiple micro-services in Laravel by Bref. However when after configuring the API gateway with the correct resources pointing to the correct lambda function. I am getting the following error and am not able to come to a solution. Please help?
{ "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: null", "stackTrace": [ "#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}" ] }
I have also configure custom domain name and did the correct API mappings.
There is some way to create a rate limit in the execution of the SQS, because I have a queue that processes sending email via SES, however I have a limitation of sending emails per second.
This package currently uses a dead-letter queue for failed jobs. This might be more in line with industry standards, but it's a bit different from "the Laravel way".
How hard would it be to use Larvels failed_jobs
table instead, so I can easily call artisan job:retry 5
?
Also, it seems that the attempts count ($job->tries
) doesn't work (#14). This also messes a bit with the default Laravel setup.
Any thoughts?
I'm using bref-php & serverless-lift & laravel-bridge library for SQS + Lambda functions, and I see that iamRoleStatement
is not attached to functions declared in constructs.
constructs:
sqs_function1:
type: queue
worker:
handler: worker.php
timeout: 600
layers:
- ${bref:layer.php-80}
vpc:
securityGroupIds:
- sg-xxxx
subnetIds:
- subnet-xxxx
- subnet-xxxx
iamRoleStatements:
- Effect: "Allow"
Action:
- "s3:*"
- "s3-object-lambda:*"
Resource: "*"
I tried like above but I couldn't make it & I couldn't find the documentation about this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.