amplify-hosting
amplify-hosting copied to clipboard
Lambda Backend - does not use python env as defined by Pipenv
Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the FAQ.
- [X] I have searched for duplicate or closed issues.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
App Id
d2jhjzrasxv9wi
Region
eu-central-1
Amplify Hosting feature
Backend builds
Describe the bug
I'm developing a react app with a Lambda (Python) Backend. I followed the guide to set up such a lambda function, and to do so I used pipenv
.
At first, I had problems in Amplify's CI/CD when building the backend because it could not find Python3.8 in the build image. I fixed that by following the solution described here: https://github.com/aws-amplify/amplify-hosting/issues/595#issuecomment-1058057237
After that succeeded, and I saw logs showing that all my dependencies were successfully installed, I noticed that my Lambda function fails because it cannot find the required dependencies.
I added a line in index.py
to show which dependencies exist and I saw that none of the dependencies configured in the Pipfile
file, were available.
So it seems like the Python environment that is running in Lambda, is not the same that was configured during the CI/CD process.
Expected behavior
Python environment having the same packages that were installed during the CI/CD pipeline, based on the Pipfile
Reproduction steps
-
cd
into the lambda function's directory - run
pipenv install flask
- import
flask
inindex.py
- Use the same build settings that are attached
- Invoke the lambda function
Build Settings
version: 1
backend:
phases:
build:
commands:
- ln -fs /usr/local/bin/pip3.8 /usr/bin/pip3
- ln -fs /usr/local/bin/python3.8 /usr/bin/python3
- export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token --domain <domain> --domain-owner <owner> --query authorizationToken --output text)
- pip3 install --user pipenv
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token --domain <domain> --domain-owner <owner> --query authorizationToken --output text)
- npm install
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Additional information
One of my dependencies are in a private CodeArtifact repository, and that's why I have CODEARTIFACT_AUTH_TOKEN
configured.
In my Pipfile
I have also changed the source url
to be my artifact repository.
Hi @sidfeiner thanks for raising this issue. We are investigating this issue and will update shortly.
Hey @hloriana , is there any update on this?
New to Amplify. Is python backend building completely broken? No movement for six months on this.. making me think I should've gone Firebase.
I'm also stuck at python3 found but version Python 3.7.15 is less than the minimum required version.[39m You must have python >= 3.8 installed and available on your PATH as "python3" or "python". It can be installed from https://www.python.org/downloads[39m [31mYou must have pipenv installed and available on your PATH as "pipenv". It can be installed by running "pip3 install --user pipenv".[39m [31mYou must have virtualenv installed and available on your PATH as "venv". It can be installed by running "pip3 install venv".
My build instructions are version: 1 frontend: phases: # IMPORTANT - Please verify your build commands build: commands: - ln -fs /usr/local/bin/pip3.9 /usr/bin/pip3 - ln -fs /usr/local/bin/python3.9 /usr/bin/python3 - pip3 install --user pipenv - amplifyPush --simple
so I don't understand why python 3.7.5 is used
Any word on this? I am getting the same error...dying.
Same problem as @neal3000, I can't see any of my build commands running in the logs.