无服务器框架,处理程序不存在

时间:2020-02-18 07:48:40

标签: php amazon-web-services aws-lambda serverless-framework serverless

我正在使用无服务器框架将PHP函数部署在AWS Lambda上。 我尝试了一个简单的示例,但是我可以在cloudwatch中看到此错误:

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

这是我的无服务器文件:

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

我的函数test.php位于文件夹public中:

<?php


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

我可以对S3Handler函数做什么? api功能正常工作。

1 个答案:

答案 0 :(得分:0)

我看到您在serverless.yml文件中将处理程序添加为 handler:public / index.php ,但是您的文件名为test.php。在我看来,这是一个打字错误。