I created a stack of lambda functions and I use the ide pycharm to test them on my localhost. In the requirements.txt file I added a reference to a private repository on github.
The repository works and I was able to install it through the requirements.txt of other projects.
But when I start the local test, using aws sam cli, sam buil fails, because the container does not have the ssh key to access the repository.
Is there any way to customize the sam build process and give it my ssh key to the container access my private repo and install the package?
Or any another solution?
This solution is written for Python, but it's probably applicable one way or another to node.js, Java etc.
I'm using the following workaround. At first it seems to defeat the purpose of building in a container, but if your private repositories are not compiled natively you should be fine. Direct dependencies that are compiled natively will be properly installed in the context of the container.
grep -v "git+" requirements.txt > public_requirements.txt
sam build --template-file "$TEMPLATE_FILE" --build-dir build --use-container --manifest public_requirements.txt
echo "Adding private dependencies"
grep "git+" requirements.txt | xargs python -m pip install --no-deps -t build/LambdaFunction/
If your private dependencies depend on libraries that are compiled natively, you can either add them to the temporary public_requirements.txt
, or install them in another container and then copy to build/LambdaFunction/
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With