我正在尝试运行symfony“bin/console”命令,如文档中所述。
运行命令
aws lambda invoke \
--function-name PhpCliLambdaName \
--region us-east-1 \
--cli-binary-format raw-in-base64-out \
--payload '"d:s:u --dump-sql"' \
response.json
字符串
退货
{
"StatusCode": 200,
"FunctionError": "Unhandled",
"ExecutedVersion": "$LATEST"
}
型
并记录此
{
"errorType": "TypeError",
"errorMessage": "Bref\\Runtime\\FileHandlerLocator::{closure}(): Argument #1 ($context) must be of type array, string given, called in /var/task/vendor/bref/bref/src/Runtime/Invoker.php on line 29",
"stack": [
"#0 /var/task/vendor/bref/bref/src/Runtime/Invoker.php(29): Bref\\Runtime\\FileHandlerLocator->{closure}('d:s:u --dump-sq...', Object(Bref\\Context\\Context))",
"#1 /var/task/vendor/bref/bref/src/Runtime/LambdaRuntime.php(89): Bref\\Runtime\\Invoker->invoke(Object(Closure), 'd:s:u --dump-sq...', Object(Bref\\Context\\Context))",
"#2 /var/task/vendor/bref/bref/src/FunctionRuntime/Main.php(37): Bref\\Runtime\\LambdaRuntime->processNextEvent(Object(Closure))",
"#3 /opt/bref/bootstrap.php(17): Bref\\FunctionRuntime\\Main::run()",
"#4 {main}"
]
}
型
- CDK*
package.json
"@bref.sh/constructs": "^1.0.0",
型
brefStack.ts
this.fpm = new PhpFpmFunction(this, 'PhpFpm', {
code,
handler: 'public/index.php',
timeout: Duration.seconds(20),
...lambdaProps,
});
this.cli = new ConsoleFunction(this, 'PhpCli', {
code,
handler: 'bin/console',
timeout: Duration.seconds(120),
...lambdaProps, // contains architecture, environment, role, securityGroups, vpc and vpcSubnets
});
型
- 交响乐-代码 *
composer.json(symfony 6.3)
"bref/bref": "^2.0",
"bref/symfony-bridge": "0.2.1",
"symfony/runtime": "6.3.*"
型
仓/控制台
#!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
return new Application($kernel);
};
型
我已经尝试过使用APP_ENV,APP_DEBUG将payload作为json对象发送,但在这种情况下,我不知道应该如何提供命令。将$context更改为string并使用$_SERVER创建内核也没有帮助。
我能够使用修改后的bin/console
和有效负载{"command":"d:s:u", "--force": true}
执行命令,但这次lambda无法返回响应并超时(但模式确实更新了)。
#!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$input = new Symfony\Component\Console\Input\ArrayInput($context);
$output = new Symfony\Component\Console\Output\BufferedOutput();
$application->run($input, $output);
return new Symfony\Component\HttpFoundation\Response($output->fetch());
};
型
在ConsoleRuntime中,我显然缺少“事件”。但我怎么能提供呢?
1条答案
按热度按时间kd3sttzy1#
自
@bref.sh/constructs
版本1.0.1
起,此问题应已解决。问题出在
cdk.json
内部的@aws-cdk/aws-lambda:recognizeVersionProps
标志设置为true。此标志可能会更改创建lambda层的顺序。如果你遇到类似的问题,试着检查你的lambda的层是否按正确的顺序排列,因为它们可以互相覆盖。