Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

transit-vpc-push-cisco-config.zip packaged on OS X fails to run in Lambda #28

Open
lucymhdavies opened this issue Aug 14, 2018 · 2 comments

Comments

@lucymhdavies
Copy link

Running the ./build-s3-dist.sh build script on macOS directly results in errors of the form:

Unable to import module 'transit_vpc_push_cisco_config/lambda_function': /var/task/bcrypt/_bcrypt.so: invalid ELF header

This seems to be because paramiko uses C wrappers for low level crypto functions, and the versions of these available on macOS do not run on Linux (and thus the lambda function does not run).

My solution to this was to build the function inside a docker container:

$ cat Dockerfile
# Docker image to build the lambda function
FROM python:2.7

RUN apt-get update && \
    apt-get install zip -y && \
    pip install --upgrade pip && \
    pip install --upgrade setuptools && \
    pip install --upgrade virtualenv

ENTRYPOINT ["/bin/bash", "-c"]

# Run with:
# docker build -t build-lambda . && docker run -it --rm -v $PWD:/tmp/workspace -w /tmp/workspace/deployment build-lambda ./build-s3-dist.sh bucket-name-here

I have a Makefile in my fork of the repo which runs this, if it's worth a pull request.
Either way, something in the README for how to build on OS X would be useful.

@vijaysat1
Copy link

Do you get similar deployment constraints on running on a EC2?. Docker container would be useful, we will further look into it and update the README accordingly for OS X. Thanks

@lucymhdavies
Copy link
Author

I've not tried building the lambda functions on an EC2 instance.
I would imagine it would work fine, given it'd be running linux.

This comment specifically was what clued me in to what was going wrong:

paramiko/paramiko#777 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants