Mohamed Taher Alrefaie
Mohamed Taher Alrefaie

Reputation: 16253

Serverless: Using a private Python package as a dependency

I have a Python Serverless project that uses a private Git (on Github) repo.

Requirements.txt file looks like this:

itsdangerous==0.24
boto3>=1.7
git+ssh://[email protected]/company/repo.git#egg=my_alias

Configurations of the project mainly looks like this

plugins:
  - serverless-python-requirements
  - serverless-wsgi
custom:
  wsgi:
    app: app.app
    packRequirements: false
  pythonRequirements:
    dockerizePip: true
    dockerSsh: true

When I deploy using this command:

sls deploy --aws-profile my_id --stage dev --region eu-west-1

I get this error:

  Command "git clone -q ssh://[email protected]/company/repo.git /tmp/pip-install-a0_8bh5a/my_alias" failed with error code 128 in None

What am I doing wrong? I'm suspecting either the way I configured my SSH key for Github access or the configurations of the serverless package.

Upvotes: 12

Views: 2729

Answers (2)

Mohamed Taher Alrefaie
Mohamed Taher Alrefaie

Reputation: 16253

So the only way I managed to sort this issue was

  1. Configure the SSH WITH NO PASSPHRASE. Following steps here.
  2. In serverless.yml, I added the following:
    custom:
      wsgi:
        app: app.app
        packRequirements: false
      pythonRequirements:
        dockerizePip: true
        dockerSsh: true
        dockerSshSymlink: ~/.ssh

Notice I added dockerSshSymlink to report the location of the ssh files on my local machine; ~/.ssh.

  1. In requirements.txt, I added my private dependency like this:

    git+ssh://[email protected]/my_comp/my_repo.git#egg=MyRepo

All works.

Upvotes: 9

dreadera
dreadera

Reputation: 19

Although not recommeneded. Have you tried using sudo sls deploy --aws-profile my_id --stage dev --region eu-west-1

This error can be also created by using the wrong password or ssh key.

Upvotes: 0

Related Questions