0.1.0 • Published 5 years ago

lambda-layer-git v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

lambda-layer-git

NPM Version Build Status Codacy Badge Coverage Status Known Vulnerabilities FOSSA Status

Add git binaries to AWS Lambda layer.

Deprecation Notice

Consider using git-lambda-layer instead, as it is compatible with all AWS runtimes (languages).

If you prefer to run git in a layer you have visibility (control) into run the following commands:

git clone https://github.com/lambci/git-lambda-layer.git
./publish.sh

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: git-lambda-layer
provider:
  name: aws
  region: us-east-1

layers:
  git:
    path: ../git-lambda-layer # using '.' clips first 2 characters
    description: Add git binaries to your lambda function
    licenseInfo: MIT
    allowedAccounts:
      - 'YOUR_AWS_ACCOUNT_ID' # use '*' to give permission to all AWS accounts
    package:
      artifact: layer.zip

Once your Lambda layer is created, it should be referenced in your lambda function.

Overview

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).

Install

$ npm install --save lambda-layer-git

AWS Lambda Layer git

Manually creating your own git layer

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.

Using serverless to create your own git layer

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.md

Using

Once your 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
  });