spotinst / spotinst-sdk-python

Spotinst SDK for the Python programming language.
Apache License 2.0
17 stars 18 forks source link

"Unable to import module 'lambda_function': No module named 'spotinst_sdk2'" #141

Closed carlzapa closed 1 year ago

carlzapa commented 1 year ago

Hi. I am creating an AWS lambda function using python and I need to use the spotinst_sdk2 library. I tried using the 2.1.35 version and also the current version (2.1.41), but I always receive the same error message:

Response { "errorMessage": "Unable to import module 'lambda_function': No module named 'spotinst_sdk2'", "errorType": "Runtime.ImportModuleError", "stackTrace": [] }

It looks like it is not able to import the spotinst_sdk2 module ..

What can I do?

Thanks in advance

anuragsharma-123 commented 1 year ago

Hi @carlzapa,

1) spotinst-sdk2 is not part of default python installation, therefore, to use it in lambda function a deployment package is to be created. It is straightforward process. Here are the instructions from AWS.

https://docs.aws.amazon.com/lambda/latest/dg/python-package.html#python-package-create-dependencies

2) All the dependencies and lambda function should be at same level inside zip file for upload. 3) Another important thing to note, default timeout of lambda functions is 3 second, where most of our REST calls will it timeout. Recommending to increase it to 1 minute in the "Configuration" tab.

Let me know if it works for you or not.

carlzapa commented 1 year ago

Hi @anuragsharma-123. It worked for me... I just needed to use 3.8 python and I also needed to increase the timeout because it takes eleven minutes to end the api calls.

Thanks