# aws-lambda

> Deploy AWS Lambda functions from command line using a json or yaml config file.

Latest version **1.0.7** (published 2021-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install aws-lambda
pnpm add aws-lambda
yarn add aws-lambda
bun add aws-lambda
```

Provides the command `lambda`.

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2021-11-07 |
| First published | 2015-01-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/aws-lambda) |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 25.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 23 |
| Author | Adrian Praja |
| Maintainers | adrian.praja |
| Keywords | lambda, aws lambda, deploy, deploy lambda |

## Links

- npm: https://www.npmjs.com/package/aws-lambda
- Repository: https://github.com/awspilot/cli-lambda-deploy
- Homepage: https://awspilot.dev
- Issues: https://github.com/awspilot/cli-lambda-deploy/issues
- npm.io page: https://npm.io/package/aws-lambda

## Dependencies (4)

- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.814.0
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.14.1
- [commander](https://npm.io/package/commander.md) ^3.0.2
- [watchpack](https://npm.io/package/watchpack.md) ^2.0.0-beta.10

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2021-11-07
- 1.0.6 — 2020-04-28
- 1.0.5 — 2020-01-06
- 1.0.4 — 2019-12-27
- 1.0.1 — 2019-12-26
- 1.0.0 — 2019-12-25
- 0.1.2 — 2016-12-06
- 0.1.1 — 2016-08-27
- 0.1.0 — 2016-08-27
- 0.0.14 — 2015-10-14
- 0.0.13 — 2015-05-18
- 0.0.12 — 2015-02-16
- 0.0.11 — 2015-01-11
- 0.0.10 — 2015-01-11
- 0.0.9 — 2015-01-11
- … 6 more at https://npm.io/package/aws-lambda/versions

## README

# cli-lambda-deploy
Command line tool deploy code to [AWS Lambda](http://aws.amazon.com/lambda/).  


[![npm test](https://github.com/awspilot/cli-lambda-deploy/actions/workflows/test.yml/badge.svg)](https://github.com/awspilot/cli-lambda-deploy/actions/workflows/test.yml)
[![Downloads](https://img.shields.io/npm/dm/aws-lambda?maxAge=2592000)](https://www.npmjs.com/package/aws-lambda)
[![Downloads](https://img.shields.io/npm/dy/aws-lambda?maxAge=2592000)](https://www.npmjs.com/package/aws-lambda)
[![Downloads](https://img.shields.io/npm/dt/aws-lambda?maxAge=2592000)](https://www.npmjs.com/package/aws-lambda)

### Notes

Versions prior to 1.0.5 suffer from "Command Injection" vulnerability,  
thanks [snyk.io](https://snyk.io/vuln) and [Song Li](http://songli.io) of Johns Hopkins University for reporting.

## Installation

```
npm install -g aws-lambda
```

WARN: upgrading to v1.0.0 will remove your function environment and layers if they are not defined in the config file  

## Config file

* PATH must point to your code folder and is relative to the config file  
* PATH can be relative or absolute  
* If not set, Runtime defaults to **nodejs10.x**  
* If not set, FunctionName defaults to the name of the config file ("my-function" in this case)  
* You can use **Ref** to reference environment variables in the form of env.YOUR_ENVIRONMENT_NAME  
* `lambda deploy <file.lambda>` credentials needs permissions to **CreateFunction**, **UpdateFunctionConfiguration** and **UpdateFunctionCode**  
* `lambda delete <file.lambda>` credentials needs permissions to **DeleteFunction**  
* `lambda invoke <file.lambda>` credentials needs permissions to **InvokeFunction**  


## Sample JSON config

```

{
	"PATH": "./test-function",
	"AWS_KEY": { "Ref" : "env.AWS_ACCESS_KEY_ID" },,
	"AWS_SECRET": { "Ref" : "env.AWS_SECRET_ACCESS_KEY"},
	"AWS_REGION": "us-east-1",

	"FunctionName": "test-lambda",
	"Role": "your_amazon_role",
	"Runtime": "nodejs10.x",
	"Handler": "index.handler",
	"MemorySize": "128",
	"Timeout": "3",
	"Environment": {
		"Variables": {
			"Hello": "World",
		}
	},
	"Layers": [
		"arn:aws:lambda:eu-central-1:452980636694:layer:awspilot-dynamodb-2_0_0-beta:1"
	],
	"Tags": {
		"k1": "v1",
		"k2": "v2"
	},
	"Description": ""
}
```

## Sample YAML config

```
# unlike json, comments are allowed in yaml, yey!
# remember to use spaces not tabs 😞
PATH: ./new-function
AWS_KEY:  !Ref "env.lambda_deploy_aws_key"
AWS_SECRET: !Ref "env.lambda_deploy_aws_secret"
AWS_REGION: "eu-central-1"

FunctionName: new-function-v12
Role: "arn:aws:iam::452980636694:role/CliLambdaDeploy-TestRole-1H89NZ845HHBK"
Runtime: "nodejs8.10"
Handler: "index.handler"
MemorySize: "128"
Timeout: "3"
Environment:
    Variables:
        Hello: "World"
Layers:
    - "arn:aws:lambda:eu-central-1:452980636694:layer:awspilot-dynamodb-2_0_0-beta:1"
Tags:
    k1: v1
    k2: v2
Description: ""
```



## Deploy from Local to AWS Lambda

```
// if installed globally then
$ lambda deploy /path/to/my-function.lambda
$ lambda deploy ../configs/my-function.lambda

// if 'npm installed' without the -g then you must use the full path
$ node_modules/.bin/lambda /path/to/my-function.lambda

// you can also add it in your scripts section of your package.json scripts: { "deploy-func1": "lambda deploy ../config/func1.lambda" }
$ npm run deploy-func1
```

## Watch config file

aws-lambda can also watch the config file and the code folder specified in the config.PATH for changes and re-reploy on change

```
$ lambda start ../configs/my-function.lambda
```

---
_Source: https://npm.io/package/aws-lambda · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
