无法在AWS lambda中使用gitpython

Nee*_*raj 3 python amazon-web-services python-2.7 gitpython aws-lambda

我一直在尝试在 aws lambda 中使用gitpython包。我使用的是python2.7环境。我使用它将gitpython与我的 python 代码捆绑到一个 zip 文件中并上传。

import json
import git

def lambda_function(event, context):
    repo="https://github.com/abc/xyz.git"
    git.Git().clone(repo)
Run Code Online (Sandbox Code Playgroud)

它说

Cmd('git') not found due to: OSError('[Errno 2] No such file or directory')
  cmdline: git clone https://github.com/abc/xyz.git: GitCommandNotFound
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 13, in lambda_function
    git.Git().clone("https://github.com/abc/xyz.git")
  File "/var/task/git/cmd.py", line 425, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "/var/task/git/cmd.py", line 877, in _call_process
    return self.execute(call, **exec_kwargs)
  File "/var/task/git/cmd.py", line 602, in execute
    raise GitCommandNotFound(command, err)
GitCommandNotFound: Cmd('git') not found due to: OSError('[Errno 2] No such file or directory')
  cmdline: git clone https://github.com/abc/xyz.git
Run Code Online (Sandbox Code Playgroud)

我认为这个错误是因为 lambda 机器中没有 git 引起的!我该如何使用这个?

sha*_*adi 8

有一个特殊的 lambda 层引入了gitlambda 函数。检查这个这个参考。基本上,

单击“层”并选择“添加层”和“提供层版本 ARN”并输入以下 ARN(将 us-east-1 替换为您的 Lambda 区域):

arn:aws:lambda:us-east-1:553035198032:层:git:6