Add git binaries to AWS Lambda layer.
This module allows loading git (version 2.13.5) as an AWS Lambda Layer so it can be used within you Lambda function (e.g. through simple-git).
$ npm install --save lambda-layer-git
For security, traceability, or other reasons it might be preferable to deploy your own git Lambda layer.
Your git lambda layer can be created manually by:
- Compressing (zipping) the following folders/files:
- bin
- nodejs
- LICENSE
- README.md
- Using the AWS CLI or AWS console to create your lambda layer and upload the zip file created in the previous step.
In case you are using the serverless framework, your git lambda layer can be created by using a serverless.yml file with the following contents:
service: lambda-layer-git
provider:
name: aws
region: us-east-1
layers:
git:
path: ../lambda-layer-git # using '.' clips first 2 characters
description: Add git binaries to your lambda function (git v2.13.5)
compatibleRuntimes:
- nodejs4.3
- nodejs6.10
- nodejs8.10
licenseInfo: MIT
allowedAccounts:
- 'YOUR_AWS_ACCOUNT_ID' # use '*' to give permission to all AWS accounts
package:
exclude:
- ./**
include:
- bin/**
- nodejs/**
- LICENSE
- README.mdOnce a Lambda layer is created, it should be referenced in your lambda function.
Invoke the lambda-layer-git module as follows:
require("lambda-layer-git").prepareGit()
.then(function () {
// git is now ready
// exec("git --version");
})
.catch(function (error) {
// something failed
});