Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I include packages in my aws lambda python deployement?

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

1 answer

0 votes

@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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Trello

Taco Tuesday: Your favorite Trello blog takeaway

Hello friends! From the community that brought you Welcome Wednesday, Throwback Thursday and Friday Fun, welcome to Taco Tuesday, a weekly discussion about all things Trello. The best part? One Tac...

67 views 4 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you