# aws-lambda-invoke

> Invoke AWS Lambda functions with ease

Latest version **3.0.0** (published 2016-10-19) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2016-10-19 |
| First published | 2015-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Sam Verschueren |
| Maintainers | samverschueren |
| Keywords | aws, lambda, invoke, async, promise, promisify, version, alias |

## Links

- npm: https://www.npmjs.com/package/aws-lambda-invoke
- Repository: https://github.com/samverschueren/aws-lambda-invoke
- Homepage: https://github.com/samverschueren/aws-lambda-invoke#readme
- Issues: https://github.com/samverschueren/aws-lambda-invoke/issues
- npm.io page: https://npm.io/package/aws-lambda-invoke

## Dependencies (2)

- [pify](https://npm.io/package/pify.md) ^2.3.0
- [parse-aws-lambda-name](https://npm.io/package/parse-aws-lambda-name.md) ^1.0.0

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2016-10-19
- 2.1.1 — 2016-02-02
- 2.1.0 — 2016-01-08
- 2.0.0 — 2015-11-04
- 1.1.0 — 2015-10-08
- 1.0.6 — 2015-09-03
- 1.0.5 — 2015-09-03
- 1.0.4 — 2015-09-02
- 1.0.3 — 2015-09-01
- 1.0.2 — 2015-09-01
- 1.0.1 — 2015-07-29
- 1.0.0 — 2015-07-29

## README

# aws-lambda-invoke [![Build Status](https://travis-ci.org/SamVerschueren/aws-lambda-invoke.svg?branch=master)](https://travis-ci.org/SamVerschueren/aws-lambda-invoke)

> Invoke AWS Lambda functions with ease


## Installation

```
npm install --save aws-lambda-invoke
```


## Usage

Make sure the `aws-sdk` is available in the project. The SDK is not shipped with this library because it is globally available in AWS Lambda. By not embedding the
SDK, you can keep te footprint of the lambda build is small as possible.

### Sychronous

The `invoke` method calls the lambda function synchronously. This means that it will wait untill the called lambda function
returns a result or fails.

```js
const lambda = require('aws-lambda-invoke');

lambda.invoke('MyLambdaFunction', {hello: 'world'}).then(result => {
    console.log(result);
    //=> '{"foo": "bar"}'
});
```

Or with an alias

```js
const lambda = require('aws-lambda-invoke');

lambda.invoke('MyLambdaFunction:production', {hello: 'world'}).then(result => {
    console.log(result);
    //=> '{"foo": "baz"}'
});
```

### Asynchronous

If you don't have to wait for the response of the lambda function you can use the `invokeAsync` method.

```js
const lambda = require('aws-lambda-invoke');

lambda.invokeAsync('MyLambdaFunction', {hello: 'world'}).then(() => {
    // invoked successfully
});
```

### Raw Lambda

If you want to do something with the lambda object created in the `aws-lambda-invoke` library, you can because the lambda function is stored
in the `raw` property of the library.

```js
const lambda = require('aws-lambda-invoke');

const params = {
    FunctionName: 'MyLambdaFunction',
    Qualifier: 'my-alias',
    InvocationType: 'RequestResponse',
    Payload: JSON.stringify({hello: 'world'})
};

lambda.raw.invoke(params, (err, result) => {
    // handle the result
});
```


## API

### invoke(name, [payload])

Returns a promise that resolves the payload returned by the invoked lambda function.

### invokeAsync(name, [payload])

Returns a promise that resolves nothing.

#### name

*Required*<br>
Type: `string`

Name of the lambda function you want to invoke. You can append the `version` or `alias` to the name separated by a colon.

#### payload

Type: `object` `string`

Payload you want to send to the lambda function you are invoking.


## License

MIT © [Sam Verschueren](https://github.com/SamVerschueren)

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