AWS Lambda
Aws-SDK-Pandas
Make it easy to use pandas with AWS services.
Create
Create the new lambda function and give the rights permissions to the role.
Configuration
TIP
Error: Runtime exited with error: signal: killed Runtime.ExitError
Provide more memory to the lambda function.
TIP
Error: Task timed out after 3.05 seconds
Increase the timeout of the lambda function.
Development
When using python with lambda, follow this pattern:
Python File Name:
lambda_function.py
Invoke Function
json
{
"first_name": "John",
"last_name": "Smith"
}
- Handler Name:
lambda_handler
python
def hello(event):
return message = 'Hello {} {}!'.format(event['first_name'], event['last_name'])
def lambda_handler(event, context):
message = hello_world(event)
print(message)
return {
'message' : message
}
Python Layers
- Create new local folder
bash
mkdir python
cd python
- Install desired package
TIP
Your zip file should have a folder named python with all content inside
bash
pip3 install --platform manylinux2014_x86_64 --only-binary=:all: --upgrade -t python pyyaml
- Create zip file
bash
zip -r pandas_layer.zip .
- AWS
Navigate to Lambda > Layers and create a layer.
Don`t forget to reference the compatibles runtimes, this will help you to add easily your layer to your function.