簡體   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