Open cameronmurphy opened 4 months ago
Why not use the console runtime? (https://bref.sh/docs/runtimes/console)
I did try but because event is an array when data is coming in from SES, this line prevents event data from getting to my handler.
Oh sorry I misread that. I think you want to use this feature instead of rebuilding it from scratch: https://github.com/brefphp/symfony-bridge?tab=readme-ov-file#class-handlers
I looked at this but I couldn't figure out how to invoke that class handler inside my Docker container locally? Only invoking plain PHP file handlers is documented.
https://bref.sh/docs/local-development/event-driven-functions#with-docker
Also which handler class would I use for SES events?
Try something like this:
docker run --rm -it -v $(PWD):/var/task:ro bref/php-81-fpm-dev:2 vendor/bin/bref-local "My\\Class"
(I think you need to escape the backslashes)
For SES there is no specific handler class. You can implement the Bref\Event\Handler
interface.
There's no documentation on how to use the docker function runtime to run a Symfony console command. My lambda function is invoked by SES, and I need access to the database, so I had to boot the Kernel.
This was my solution src/LambdaKernel.php:
bin/lambda-handler.php:
Dockerfile:
The real gotcha was preventing the application from auto exiting, which was putting the application into a loop and running the console command repeatedly.
Maybe it's just a really niche use case, but I was surprised by how difficult it was to deploy a single Symfony console command as a dockerised lambda function (where I don't have to invoke with specific arguments).