1

I'm trying to run a (Symfony) PHP application on LocalStack (AWS Lambda). As recommended by the Bref docs, I use the ${bref:layer.php-81-fpm} layer. Invoking a function fails and the LocalStack logs say:

ALERT: [pool default] user has not been defined

This leads to Bref's PHP-FPM config, where the user nobody is configured for the default pool. This user exists in the LocalStack docker image, but my guess is that it does not exist in LocalStack's lambda executor image (when using non-FPM PHP, it is invoked under root). What speaks against this assumption is that the error message is the same when setting LAMBDA_EXECUTOR=local, but I'm too new to LocalStack to be sure about what's really happening.

So my question is how to resolve this. Maybe I could hack Bref's PHP config and switch to root. But I'd prefer to adjust LocalStack instead so that Bref can be configured the same as in production (and especially not as root). Maybe the Lambda executor user can be changed? I didn't find anything about it though.

Btw on a real AWS environment everything works as expected.

Using LocalStack 0.13.3 in Docker, Bref 1.5.2 with PHP 8.1 layer.

Thanks for help!

umulmrum
  • 153
  • 1
  • 8

1 Answers1

0

To run PHP-FPM with Bref on LocalStack:

  1. Update to the latest LocalStack version docker pull localstack/localstack-pro (at least after Feb 16, 2023)
  2. Start LocalStack with the Configuration PROVIDER_OVERRIDE_LAMBDA=v2 (until the new lambda provider implementation becomes default with LocalStack v2)
  3. Add the configuration LAMBDA_DOCKER_FLAGS=--user nobody (until this user permission issue is resolved for running fpm as user nobody)

The sample project lambda-php-bref-cdk-app provides a "simple PHP/Bref serverless application using a shared Lambda layer deployable with AWS CDK to LocalStack." It showcases a typed PHP Lambda handler and provides instructions on how to run traditional php-fpm applications.

The default Lambda executor LAMBDA_EXECUTOR=docker-reuse is recommended. The docker-compose-pro.yml from the LocalStack repository shows how to mount the Docker socket required for using the Docker executor.

joe4dev
  • 1
  • 2