10
votes

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.

2
1. When cloning from Github with the ssh url, you have to provide the ssh key, so if you need ssh clone, you have to put the private key into container and setup the ssh agent. 2. What is ssh clone necessary for in the container anyway? You're just installing the package without planning to change the upstream code etc, so replace the requirements url with https://github.com/company/repo.git#egg=my_alias and ready. - hoefling
@hoefling, that is what dockerSsh: true, it maps the keys from outside to inside the container. M-T-A, can you add --verbose flag to your deploy command and share the output of the same - Tarun Lalwani
What version of serverless-python-requirements do you use? - Andrii Maletskyi
also, do you run sls deploy in interactive shell or via some build system? If you run it in console, you can authenticate interactively using git+https:// - Andrii Maletskyi

2 Answers

9
votes

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.

0
votes

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.