Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

updating readme #159

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.8.5 (2024-03-09)
- [Bugfix: Look for matching layer](https://github.com/agutoli/serverless-layers/pull/157)
- [Bugfix: Remove aws-sdk from nodejs layerOptimization.cleanupPatterns](https://github.com/agutoli/serverless-layers/pull/151)

# 2.6.1 (2022-12-23)
- [dependabot mocha](https://github.com/agutoli/serverless-layers/commit/4aca58091e6bf0472e12814513fd800590ae5705)
- [Bugfix: Unable to attach layers to the existing lambda](https://github.com/agutoli/serverless-layers/issues/97)
Expand Down
126 changes: 65 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
# serverless-layers
# Serverless Layers

[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)
[![Issues](https://img.shields.io/github/issues/agutoli/serverless-layers.svg)](https://github.com/agutoli/serverless-layers/issues) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://www.npmjs.com/package/serverless-layers)
[![NPM](https://img.shields.io/npm/v/serverless-layers.svg)](https://www.npmjs.com/package/serverless-layers)
[![Build Status](https://travis-ci.org/agutoli/serverless-layers.svg?branch=master)](https://travis-ci.org/agutoli/serverless-layers)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing)
![Node.js CI](https://github.com/agutoli/serverless-layers/workflows/Node.js%20CI/badge.svg)
* It attaches automatically layers to the provider and for each function
* it will skip functions with no other layers as they will use the layer(s) we added to the provider
* It creates a new layer's version when `dependencies` is updated
* If `dependencies` is not changed, it does not publish a new layer
* It reduces drastically lambda size
* It reduces deployment time.
* You can share same layers (libraries) among all lambda functions

# Options

* Automatically attaches layers to the provider and for each function
* Skips functions with no other layers as they will use the layer(s) we added to the provider
* Creates a new layer's version when `dependencies` are updated
* Does not publish a new layer if `dependencies` are unchanged
* Drastically reduces lambda size
* Reduces deployment time
* Allows sharing of the same layers (libraries) among all lambda functions

## Options

* [NodeJS](#nodejs)
* [Ruby](#ruby)
* [Python](#python)

## Common requirements
## Common Requirements

* AWS only (sorry)
* Serverless >= 1.34.0 (layers support)


## Install

`npm install -D serverless-layers`
```bash
npm install -D serverless-layers
```

or

`serverless plugin install --name serverless-layers`
```bash
serverless plugin install --name serverless-layers
```

Add the plugin to your `serverless.yml` file:

## Single layer config

Example:

```yaml
Expand All @@ -54,6 +62,7 @@ functions:
```

## Multiple layers config

Example:

```yaml
Expand Down Expand Up @@ -85,81 +94,79 @@ functions:

![Screen Shot 2020-04-05 at 2 04 38 pm](https://user-images.githubusercontent.com/298845/78466747-2fb58f80-7748-11ea-948d-4fce40a753bb.png)


| Option | Type | Default | Description |
| -------------- | --------- | ----------- | ----------- |
| compileDir | `string` | .serverless | Compilation directory |
| layersDeploymentBucket | `string` | | You can specify a bucket to upload lambda layers. `Required if deploymentBucket is not defined.` |
| customInstallationCommand | `string` | | It specify a custom command to install deps ex. `MY_ENV=1 npm --proxy http://myproxy.com i -P` |
| customHash | `string` | | Can specify custom string, that once changed will force a new build of the layer
| retainVersions | `int` | `null` | Number of layer versions to keep, the rest versions will be removed after deployments |

| Option | Type | Default | Description |
|------------------------------|----------|-----------------|------------------------------------------|
| compileDir | `string` | .serverless | Compilation directory |
| layersDeploymentBucket | `string` | | Specify a bucket to upload lambda layers. `Required if deploymentBucket is not defined.` |
| customInstallationCommand | `string` | | Specify a custom command to install dependencies, e.g., `MY_ENV=1 npm --proxy http://myproxy.com i -P` |
| customHash | `string` | | Specify a custom string that, once changed, will force a new build of the layer |
| retainVersions | `int` | `null` | Number of layer versions to keep; older versions will be removed after deployments |

## NodeJS

### Requirements

* Node >= v6.10.3
* NPM >= 3.10.10
* A valid package.json file
* A valid `package.json` file

### Options

| Option | Type | Default | Description |
| -------------- | --------- | ----------- | ----------- |
| packageManager | `string` | npm | Possible values: npm, yarn |
| packagePath | `string` | package.json | `(DEPRECATED)`: Available for `<= 1.5.0`, for versions `>= 2.x` please use `compatibleRuntimes` |
| dependenciesPath | `string` | package.json | Note: `>= 2.x` versions. You can specify custom path for your package.json |
| compatibleRuntimes | `array` | `['nodejs']` | Possible values: nodejs, nodejs10.x, nodejs12.x |
| layerOptimization.cleanupPatterns | `array` | [check](https://github.com/agutoli/serverless-layers/blob/master/src/runtimes/nodejs.js) | The pattern of files to cleanup in the layer artifact before uploading it. |

----------------------
| Option | Type | Default | Description |
|-----------------------------|----------|-----------------|--------------------------------------------------------------|
| packageManager | `string` | npm | Possible values: npm, yarn |
| packagePath | `string` | package.json | `(DEPRECATED)`: Available for `<= 1.5.0`; for versions `>= 2.x`, use `compatibleRuntimes` |
| dependenciesPath | `string` | package.json | Note: `>= 2.x` versions. You can specify a custom path for your `package.json` |
| compatibleRuntimes | `array` | `['nodejs']` | Possible values: nodejs, nodejs10.x, nodejs12.x |
| layerOptimization.cleanupPatterns | `array` | [check](https://github.com/agutoli/serverless-layers/blob/master/src/runtimes/nodejs.js) | Pattern of files to cleanup in the layer artifact before uploading it |

## Ruby

### Requirements

* Ruby >= 2.5
* A valid Gemfile file
* A valid `Gemfile` file

### Options

| Option | Type | Default | Description |
| -------------- | --------- | ----------- | ----------- |
| packageManager | `string` | bundle | Possible values: bundle |
| dependenciesPath | `string` | Gemfile | Note: Available for `>= 2.x` versions. You can specify custom path for your requirements.txt |
| compatibleRuntimes | `array` | `['ruby']` | Possible values: ruby2.5, ruby2.7 |
| layerOptimization.cleanupPatterns | `array` | [check](https://github.com/agutoli/serverless-layers/blob/master/src/runtimes/ruby.js) | The pattern of files to cleanup in the layer artifact before uploading it. |

----------------------
| Option | Type | Default | Description |
|-----------------------------|----------|-----------------|--------------------------------------------------------------|
| packageManager | `string` | bundle | Possible values: bundle |
| dependenciesPath | `string` | Gemfile | Note: Available for `>= 2.x` versions. You can specify a custom path for your `Gemfile` |
| compatibleRuntimes | `array` | `['ruby']` | Possible values: ruby2.5, ruby2.7 |
| layerOptimization.cleanupPatterns | `array` | [check](https://github.com/agutoli/serverless-layers/blob/master/src/runtimes/ruby.js) | Pattern of files to cleanup in the layer artifact before uploading it |

## Python

### Requirements

* Python >= 2.7
* A valid requirements.txt file
* A valid `requirements.txt` file

### Options
| Option | Type | Default | Description |
| -------------- | --------- | ----------- | ----------- |
| packageManager | `string` | pip | Possible values: pip |
| dependenciesPath | `string` | requirements.txt | Note: Available for `>= 2.x` versions. You can specify custom path for your requirements.txt |
| compatibleRuntimes | `array` | `['python']` | Possible values: python2.7, python3.x |
| layerOptimization.cleanupPatterns | `array` | [check](https://github.com/agutoli/serverless-layers/blob/master/src/runtimes/python.js) | The pattern of files to cleanup in the layer artifact before uploading it. |

----------------------
| Option | Type | Default | Description |
|-----------------------------|----------|-----------------|--------------------------------------------------------------|
| packageManager | `string` | pip | Possible values: pip |
| dependenciesPath | `string` | requirements.txt | Note: Available for `>= 2.x` versions. You can specify a custom path for your `requirements.txt` |
| compatibleRuntimes | `array` | `['python']` | Possible values: python2.7, python3.x |
| layerOptimization.cleanupPatterns | `array` | [check](https://github.com/agutoli/serverless-layers/blob/master/src/runtimes/python.js) | Pattern of files to cleanup in the layer artifact before uploading it |

## Default Serverless Setup

This plugin will setup follow options automatically if not specified at `serverless.yml`.
This plugin will set up the following options automatically if not specified in `serverless.yml`.

| Option | Type | Default |
| -------------- | --------- | ----------- |
| package.individually | `bool` | false |
| package.patterns | `array` | `['node_modules/**']` |
| package.excludeDevDependencies | `bool` | false |
| Option | Type | Default |
|-----------------------------|----------|-----------------|
| package.individually | `bool` | false |
| package.patterns | `array`| `['node_modules/**']` |
| package.excludeDevDependencies | `bool` | false |

## Mininal Policy permissions for CI/CD IAM users

## Minimal Policy permissions for CI/CD IAM users

`serverless-layers-policy.json`

```json
{
"Version":"2012-10-17",
Expand Down Expand Up @@ -196,10 +203,7 @@ MIT

## Contributors

Yes, thank you!
This plugin is community-driven, most of its features are from different authors.
Please update the docs and tests and add your name to the package.json file.
We try to follow [Airbnb's JavaScript Style Guide](https://github.com/airbnb/javascript).
Yes, thank you! This plugin is community-driven, and most of its features are from different authors. Please update the docs and tests and add your name to the `package.json` file. We try to follow [Airbnb's JavaScript Style Guide](https://github.com/airbnb/javascript).

<!-- Copy-paste in your Readme.md file -->

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-layers",
"version": "2.8.4",
"version": "2.8.5",
"description": "",
"main": "lib/index.js",
"bugs": {
Expand Down
Loading