Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(lambda-layer-awscli): error while loading shared libraries: libpython2.7.so.1.0 #13979

Closed
tai-acall opened this issue Apr 5, 2021 · 4 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@tai-acall
Copy link

Reproduction Steps

Follow the instruction in document page to import module @aws-cdk/lambda-layer-awscli
https://docs.aws.amazon.com/cdk/api/latest/docs/lambda-layer-awscli-readme.html

CDK Stack

import * as cdk from '@aws-cdk/core';
import { NodejsFunction } from '@aws-cdk/aws-lambda-nodejs'
import * as awscliLayer from '@aws-cdk/lambda-layer-awscli'
import * as lambda from '@aws-cdk/aws-lambda'

export class LamdbaStackForceEcsDeploy extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const fn = new NodejsFunction(this, 'demo', {
      entry: 'src/stacks/lambda/handler/entry.ts',
      runtime: lambda.Runtime.NODEJS_12_X,
      memorySize: 512,
      timeout: cdk.Duration.seconds(30),
      environment:
        {
          'LD_LIBRARY_PATH':'/opt/awscli/lib',
          'PYTHONHOME':'/opt/awscli/lib/python2.7',
          'PYTHONPATH':'/opt/awscli/lib/python2.7:/opt/awscli/lib/python2.7/lib-dynload'
        }
    });

    fn.addLayers(new awscliLayer.AwsCliLayer(this, 'AwsCliLayer'));
  }
}

Handler code

import {APIGatewayEventRequestContext, APIGatewayProxyEvent, APIGatewayProxyResult} from 'aws-lambda';

export async function handler(
  event: APIGatewayProxyEvent,
  context: APIGatewayEventRequestContext
): Promise<APIGatewayProxyResult> {

  const shell = require('child_process').execSync
  const version = shell('/opt/awscli/aws --version')
  console.log(version)
  return {
    statusCode: 201,
    body: JSON.stringify({
      id: 'test-id',
      cliver: version
    })
  }
}

While I invoke the lambda function test in the AWS Management console, return error.

What did you expect to happen?

It should return the aws cli version.

I just done my research and I think this module should work in nodejs 12 runtime.

aws-samples/aws-lambda-layer-awscli#5 (comment)

What actually happened?

{
  "errorType": "Error",
  "errorMessage": "Command failed: /opt/awscli/aws --version\n/opt/awscli/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory\n",
  "trace": [
    "Error: Command failed: /opt/awscli/aws --version",
    "/opt/awscli/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory",
    "",
    "    at checkExecSyncError (child_process.js:635:11)",
    "    at execSync (child_process.js:671:15)",
    "    at Runtime.handler (/var/task/index.js:15:19)",
    "    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
  ]
}

Environment

  • CDK CLI Version : "@aws-cdk/core": "1.96.0"
  • Framework Version:
  • Node.js Version:
  • OS :
  • Language (Version): TypeScript (4.2.3)

Other


This is 🐛 Bug Report

@tai-acall tai-acall added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 5, 2021
@tai-acall
Copy link
Author

is @aws-cdk/lambda-layer-awscli module include layer-build-python27 layer?

just read the following document and I'm confusing now.

https://github.com/aws-samples/aws-lambda-layer-awscli#node10-and-node12-aws-lambda-runtime-support

@pahud
Copy link
Contributor

pahud commented Apr 6, 2021

Hi I am the maintainer of aws-samples/aws-lambda-layer-awscli. The @aws-cdk/lambda-layer-awscli cdk construct library has nothing to do with aws-samples/aws-lambda-layer-awscli. If you check https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/lambda-layer-awscli/layer , you will see how @aws-cdk/lambda-layer-awscli was bundled in this Dockerfile.

In the near future, I am planing to align aws-samples/aws-lambda-layer-awscli with @aws-cdk/lambda-layer-awscli so we can simply deploy or own awscli lambda layer from @aws-cdk/lambda-layer-awscli or simply customize it by editing the Dockerfile.

@tai-acall
Copy link
Author

@pahud
thanks for reply.

I think I should wait for this update aws-samples/aws-lambda-layer-awscli#39.

@github-actions
Copy link

github-actions bot commented Apr 7, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants