git error while loading shared libraries on nodejs10.x
Closed this issue · 1 comments
mxfactorial commented
steps
-
create bucket
aws s3api create-bucket \ --bucket unique-bucket-random-123 \ --region us-east-1
-
save index.js
const util = require('util') const exec = util.promisify(require('child_process').exec) const REPO = 'https://github.com/gkrizek/bash-lambda-layer.git' const TMP_DIR = '/tmp/bash-lambda-layer/examples' exports.handler = async event => { await exec(`cd /tmp && git clone --depth 1 --single-branch --branch master ${REPO}`) let lsOutput = await exec(`ls ${TMP_DIR}`) if (lsOutput.errorMessage) { return lsOutput.errorMessage } }
-
zip index.js
zip src.zip index.js
-
put zip in s3
aws s3api put-object \ --bucket=unique-bucket-random-123 \ --key=src.zip \ --body=src.zip
-
save
template.yaml
referencing bash layer innodejs10.x
lambdaAWSTemplateFormatVersion: "2010-09-09" Description: "bash8 layer bug on nodejs10.x" Parameters: BucketName: Type: String Resources: SharedLibraryBugRepoLambda: Type: AWS::Lambda::Function Properties: FunctionName: bash8-layer-bug-on-nodejs10 Description: "repro libcurl.so.4: cannot open shared object file" Handler: index.handler Role: !GetAtt SharedLibraryBugRepoLambdaRole.Arn Runtime: nodejs10.x Timeout: 10 Layers: - !Sub "arn:aws:lambda:${AWS::Region}:744348701589:layer:bash:8" Code: S3Bucket: !Sub ${BucketName} S3Key: src.zip SharedLibraryBugRepoLambdaRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Principal: Service: - lambda.amazonaws.com Action: - 'sts:AssumeRole' Path: / Policies: - PolicyName: SharedLibraryBugRepoLambdaLoggingPolicy PolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Action: - 'logs:CreateLogGroup' - 'logs:CreateLogStream' - 'logs:PutLogEvents' Resource: 'arn:aws:logs:*:*:*' SharedLibraryBugRepoLambdaLogGroup: Type: AWS::Logs::LogGroup DependsOn: - SharedLibraryBugRepoLambda Properties: RetentionInDays: 90 LogGroupName: !Sub /aws/lambda/${SharedLibraryBugRepoLambda}
-
provision template
aws cloudformation create-stack \ --capabilities CAPABILITY_NAMED_IAM \ --stack-name bash8-layer-bug-on-nodejs10x \ --template-body file://$(pwd)/template.yaml \ --parameters ParameterKey=BucketName,ParameterValue=unique-bucket-random-123
-
invoke lambda
aws lambda invoke \ --invocation-type RequestResponse \ --function-name bash8-layer-bug-on-nodejs10 \ --payload '{}' \ invoke.log \ && cat invoke.log
observed
{"errorType":"Error","errorMessage":"Command failed: cd /tmp && git clone --depth 1 --single-branch --branch master https://github.com/gkrizek/bash-lambda-layer.git\nCloning into 'bash-lambda-layer'...\n/opt/libexec/git-core/git-remote-https: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory\n","trace":["Error: Command failed: cd /tmp && git clone --depth 1 --single-branch --branch master https://github.com/gkrizek/bash-lambda-layer.git","Cloning into 'bash-lambda-layer'...","/opt/libexec/git-core/git-remote-https: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory",""," at ChildProcess.exithandler (child_process.js:294:12)"," at ChildProcess.emit (events.js:198:13)"," at maybeClose (internal/child_process.js:982:16)"," at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)"]}
*teardown:
aws cloudformation delete-stack --stack-name bash8-layer-bug-on-nodejs10x
aws s3api delete-object --bucket unique-bucket-random-123 --key src.zip
aws s3api delete-bucket --bucket unique-bucket-random-123
gkrizek commented
Sorry for the late response. You can't use this layer with any runtime other than provided
. When you use runtime nodejs10.x
it invoke the node.js bootstrap file, not this one. And I'm sure there's other differences in the environment that I don't know about.