aws-samples/php-examples-for-aws-lambda

entrypoint requires the handler name to be the first argument

tho-actrecipe opened this issue · 2 comments

Hi everyone,

I'm trying to build the local environment for develop Lambda functions with PHP.

I modify the Dockerfile (https://github.com/aws-samples/php-examples-for-aws-lambda/blob/master/0.7-PHP-Lambda-functions-with-Docker-container-images/Dockerfile)

CMD ["index", "_HANDLER=/tasks/get_data"]

Then got the error

entrypoint requires the handler name to be the first argument

What should the handler name be?

Example I have the /tasks folder that contains the functions get_data, post_data.
For serverless.yml, it will be config like this

functions:
  task_get_data:
    timeout: 60
    handler: tasks/get_data.php
    layers:
      -  ${bref:layer.php-73}
  task_post_data:
    timeout: 60
    handler: tasks/post_data.php
    layers:
      -  ${bref:layer.php-73}

How can I test these functions in local with docker container images?

I'm looking forward to your help.
Thank you so much.

You can test locally using the RIE (runtime interface emulator )https://docs.aws.amazon.com/lambda/latest/dg/images-test.html).

It looks like your are using serverless framework to define your Lambda functions? Take a look at their documentation to see how this changes for creating Lambda functions from container images.
eg. Rather than define a handler you just specify the image.

https://www.serverless.com/blog/container-support-for-lambda

@bls20AWS Thank you for your help. I will check it out.