【问题标题】:Error libncurses.so.6 when using Bref Lambda custom runtime with AWS CDK将 Bref Lambda 自定义运行时与 AWS CDK 一起使用时出现错误 libncurses.so.6
【发布时间】:2021-07-07 14:03:49
【问题描述】:

我正在尝试使用 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

如果我将部署与无服务器框架进行比较,配置(层、代码等)几乎相同。我错过了什么?

【问题讨论】:

    标签: php amazon-web-services aws-lambda bref


    【解决方案1】:

    事实证明,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,
        });
    

    【讨论】:

      猜你喜欢
      • 2017-10-25
      • 1970-01-01
      • 2016-04-06
      • 2016-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-12
      相关资源
      最近更新 更多