php - 将 Bref Lambda 自定义运行时与 AWS CDK 一起使用时出现错误 libncurses.so.6
问题描述
我正在尝试使用 AWS CDK 而不是 Serverless 在 AWS Lambda 中使用 Bref 自定义运行时。
CDK 代码如下所示。
const region = cdk.Stack.of(this).region;
//arn:aws:lambda:ap-southeast-1:209497400698:layer:php-74:18
const brefLayerVersion = `arn:aws:lambda:${region}:209497400698:layer:php-80:8`;
const assetPath = path.join(__dirname, '../../lambda');
const asset = lambda.Code.fromAsset(assetPath);
const lambdaFunc = new lambda.Function(this, 'LambdaFunction', {
runtime: lambda.Runtime.PROVIDED,
handler: 'src/index.php',
layers: [
lambda.LayerVersion.fromLayerVersionArn(this, 'BrefPHPLayer', brefLayerVersion),
],
code: asset,
});
new cdk.CfnOutput(this, 'LambdaFunctionArn', { value: lambdaFunc.functionArn });
这是完整的源代码https://github.com/petrabarus/cdk-bref-function
当我尝试使用 AWS CLI 手动调用时aws lambda invoke --function-name arn:blabla
,它显示错误。
Cloudwatch 日志显示类似这样的内容。
/opt/bin/php: error while loading shared libraries: libncurses.so.6: cannot open shared object file: No such file or directory
如果我将部署与无服务器框架进行比较,配置(层、代码等)几乎相同。我错过了什么?
解决方案
事实证明,Bref 1.0 需要提供 Amazon Linux 2 运行时。这是更新的 CDK 代码。
const lambdaFunc = new lambda.Function(this, 'LambdaFunction', {
runtime: lambda.Runtime.PROVIDED_AL2,
handler: 'src/index.php',
layers: [
lambda.LayerVersion.fromLayerVersionArn(this, 'BrefPHPLayer', brefLayerVersion),
],
code: asset,
});
推荐阅读
- javascript - 排毒 textInput 不写文本
- google-apps-script - 如何根据另一列中的另一个值是否存在匹配来设置单元格的值?
- oracle - 如何将字符串列表传递给 Olracle 中的存储过程
- node.js - Heroku 上的 Redis 连接错误:127.0.0.1 而不是 REDIS_URL
- bixby - 如何调试与惰性属性相关的问题?
- jquery - 选项卡中的值显示为 NaN
- c++-winrt - 如何从键盘事件更改堆栈面板的视觉状态
- sql-server - 来自 SQL Server 的 EPOCH 时间戳
- c++ - C++:创建 Web 服务
- sequelize.js - 如何在 Sequelize ORM 中获得 Y 最多的前 X 个用户?