I did try the 2 solutions - nesting properly my Python libs inside zip folder:
layer_content.zip
└ python
└ lib
└ python3.11
└ site-packages
└ requests
└ <other_dependencies> (i.e. dependencies of the requests package)
└ ...
and following another tip that Amazon just changed its requirement and all libs should go directly into python folder. But both options don't work.
my_layer.zip:
- python
- requests
- psycopg2
- snowflake-connector
my_layer_nested.zip:
└ python
└ lib
└ python3.11
└ site-packages
└ requests
└ snowflake-connector
Neither work, it does not see the requests module:
import json
import requests
def lambda_handler(event, context):
url = ";
response = requests.get(url)
return {
'statusCode': 200,
'body': json.dumps({
'message': 'Layer test successful!',
'data': response.json()
})
}
I tried using both separate zip folders as layers, here is the output:
Status: Failed
Test Event Name: kljlj
Response:
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'requests'",
"errorType": "Runtime.ImportModuleError",
"requestId": "",
"stackTrace": []
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744663247a4586591.html
评论列表(0条)