3
votes

I'm using the Serverless framework to deploy my PHP functions on the AWS Lambda. I have tried with a simple example but I can see inside cloudwatch this error:

Handler `/var/task/public/test.hello` doesn't exist

This is my serverless file:

service: symfony-bref

provider:
    name: aws
    region: eu-central-1
    runtime: provided
    environment:
        APP_ENV: prod

plugins:
    - ./vendor/bref/bref

functions:
    api:
        handler: public/index.php
        description: ''
        timeout: 30 # in seconds (API Gateway has a timeout of 30 seconds)
        layers:
            - ${bref:layer.php-73-fpm}
        events:
            -   http: 'ANY /'
            -   http: 'ANY /{proxy+}'

    S3Handler:
        handler: public/test.hello
        layers:
            - ${bref:layer.php-73}
        events:
            - s3:
                bucket: ${ssm:/symfony-bref/AWS_S3_BUCKET_NAME:1}
                event: s3:ObjectCreated:*
                existing: true

and my functions test.php is inside the folder public:

<?php


function hello($eventData) : array
{
    return ["msg" => "hello from PHP " . PHP_VERSION];
}

What can I do for function S3Handler? Api function is working fine.

1

1 Answers

0
votes

I see you have added handler as handler: public/index.php in serverless.yml file, but your file name is test.php. It seems to me like a typing mistake.