Hi,
I am trying to create a bitbucket pipeline to deploy my python code to AWS Lambda. My test function is very simple:
import pandas as pd
import numpy as np
def get_dashboard_url(event, context):
t = pd.DataFrame()
print(np.exp(2))
I managed to deploy the function but every time I run it I have an error: "No module named 'pandas'".
Here is my .yml file:
image: python:3.6
pipelines:
default:
- step:
name: Build and package
script:
- apt-get update && apt-get install -y zip
- mkdir packages
- pip install -r requirements.txt -t ./packages
- zip -r code.zip ./packages
- zip -g code.zip dashboard_url.py
artifacts:
- code.zip
- step:
name: Update Lambda code
script:
- pipe: atlassian/aws-lambda-deploy:0.2.1
variables:
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_DEFAULT_REGION: '*****'
FUNCTION_NAME: '*****'
COMMAND: 'update'
ZIP_FILE: 'code.zip'
I don't know what i am doing wrong
Thanks in advance for any help
Matthias
@Matthias Leroyyou install dependencies to packages folder , that your aws lambda function knows nothing about.
Your dependencies should be in the root.
My code has worked for me with your dependencies. See example:
script:
- apt-get update && apt-get install -y zip
- mkdir lambda_build
- cp lambda_function.py lambda_build/ && cd lambda_build
- pip install numpy pandas -t .
- zip -r code.zip . -x '*.pyc' -x '*__pycache__*'
artifacts:
- "lambda_build/code.zip"
Then put in the deploy section variable ZIP_FILE to "lambda_build/code.zip"
Regards, Galyna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.