2

I am continually running into problems importing a module to use on AWS.

Specifically, the Coinbase library.

I have followed the AWS Lambda docs, and have created a folder called packages, installed all the libraries into that folder, then zipped up that with my function.

I can get the function to work if I comment out all the Coinbase code and import statement, so that tells me that the zipping and uploading is fine.

Specific error is

{
  "errorMessage": "Unable to import module 'lambda_function': No module named 'coinbase'",
  "errorType": "Runtime.ImportModuleError"
}

I can see plane as day that the coinbase library is sitting in the package folder, so I'm not sure why AWS can't access it.

I've tried chmod 444, still no success.

Has anyone had any experience with resolving a package not running on lambda like this?

1 Answer 1

2

You need to launch an EC2 for creating layers. Look up at Runtimes for the AMI of the instance. For example Python 3.6 uses AWS Linux 1.

In that instance you need to install Python 3.6 and execute the following commands:

sudo su
mkdir -p temp/python
cd temp/python
pip-3.6 install coinbase -t .
cd ..
zip -r9 ../coinbase .zip .

Extract this zip for example using SFTP and upload to AWS Lambda Layers. Your layer will work perfectly.

Attach the layer to the functions in which you would like to use that package

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.