I am using sst
to deploy a Python lambda function.
When I am trying to deploy it in Github actions, I get this error from the lambda.
ModuleNotFoundError: No module named 'asyncpg.protocol.protocol'
This lambda is executed as part of the deployment. Usually, I get this error on my local machine when I am not in the Python virtual environment.
During the SST deployment, I can see the Python dependencies installed. Some how the lambda does not have the dependencies linked.
Step 10/11 : RUN if [ -f 'requirements.txt' ]; then pip install -r requirements.txt -t .; else echo "requirements.txt not found"; fi
---> Running in 8a0ba257899d
Collecting aerich==0.7.1 (from -r requirements.txt (line 2))
Downloading aerich-0.7.1-py3-none-any.whl (37 kB)
Collecting aiosqlite==0.17.0 (from -r requirements.txt (line 3))
Downloading aiosqlite-0.17.0-py3-none-any.whl (15 kB)
Collecting anyio==3.7.0 (from -r requirements.txt (line 4))
Downloading anyio-3.7.0-py3-none-any.whl (80 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.9/80.9 kB 22.0 MB/s eta 0:00:00
Collecting asyncpg==0.27.0 (from -r requirements.txt (line 5))
Downloading asyncpg-0.27.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (2.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.7/2.7 MB 91.3 MB/s eta 0:00:00
Collecting auth0-python==4.2.0 (from -r requirements.txt (line 6))
I can successfully deploy it on my local machine. Also, I can deploy in AWS Linux machine in EC2. For some reason I can't use Github Action to deploy it.
jobs:
deploy:
environment: 'development'
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
id-token: write
steps:
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ vars.AWS_DEPLOYMENT_ROLE }}
aws-region: ${{ vars.AWS_REGION }}
- name: Checkout repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Install root dependencies
run: |
git config --global --add safe.directory /__w/app
yarn
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: deploy
run: |
cd backend
pip install -r requirements.txt
cd ..
npx sst deploy --stage test