繁体   English   中英

将 Bref Lambda 自定义运行时与 AWS CDK 一起使用时出现错误 libncurses.so.6

[英]Error libncurses.so.6 when using Bref Lambda custom runtime with AWS CDK

我正在尝试使用 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,
    });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM