title: Running 'git' in AWS lambda
body: <p>I am trying to run git in AWS lambda to make a checkout of a repository.</p>
  
  <p>This is my setup:</p>
  
  <ul>
  <li>I am using nodejs 4.3</li>
  <li>I am not using <a href="https://github.com/nodegit/nodegit" rel="noreferrer">nodegit</a> because I want to use the "--depth=1" parameter, which is not supported by nodegit.</li>
  <li>I have copied the git and ssh executable from the correct AWS AMI and placed then in a "bin" folder in the zip I upload.</li>
  <li>I added them to PATH with this:</li>
  </ul>
  
  <p>-></p>
  
  <pre><code>process.env['PATH'] = process.env['LAMBDA_TASK_ROOT'] + "/bin:" + process.env['PATH'];
  </code></pre>
  
  <p>The input variables are set like this:</p>
  
  <pre><code>"checkout_url": "git@...",
  "branch":"master
  </code></pre>
  
  <p>Now I do this (for brevity, I mixed some pseudo-code in):</p>
  
  <pre><code>downloadDeploymentKeyFromS3Sync('/tmp/ssh_key');
  fs.chmodSync("/tmp/ssh_key",0600);
  process.env['GIT_SSH_COMMAND'] = 'ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key';
  execSync("git clone --depth=1 " + checkout_url + " --branch " + branch + " /tmp/checkout");
  </code></pre>
  
  <p>Running this in my local computer using <a href="https://www.npmjs.com/package/lambda-local" rel="noreferrer">lambda-local</a> everything works fine! But when I test it in lambda, I get:</p>
  
  <pre><code>warning: templates not found /usr/share/git-core/templates
  PRIV_END: seteuid: Operation not permitted\r
  fatal: Could not read from remote repository.
  </code></pre>
  
  <ul>
  <li>The "warning" is of course, because I did not install git but just copied the binary. Is that a reason why this should not work?</li>
  <li>Why is git needing "setuid"? I read that in some shells, that is disabled for security reasons. So it makes sense that it does not work in lambda. Can git somehow be instructed to not "need" this command?</li>
  </ul>