# aws-opensearch-connection

> AWS Opensearch connection for the @opensearch-project/opensearch ES client

Latest version **3.0.0** (published 2021-10-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install aws-opensearch-connection
pnpm add aws-opensearch-connection
yarn add aws-opensearch-connection
bun add aws-opensearch-connection
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2021-10-29 |
| First published | 2021-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Acuris |
| Maintainers | erpox |
| Keywords | aws, opensearch, es, @opensearch-project/opensearch-project, connection, signing, elastic, search |

## Links

- npm: https://www.npmjs.com/package/aws-opensearch-connection
- Repository: https://github.com/erpox/acuris-aws-es-connection
- Homepage: https://github.com/erpox/acuris-aws-es-connection#readme
- Issues: https://github.com/erpox/acuris-aws-es-connection/issues
- npm.io page: https://npm.io/package/aws-opensearch-connection

## Dependencies (1)

- [aws4](https://npm.io/package/aws4.md) ^1.11.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2021-10-29

## README

# AWS ES Connection

This is a form from the acuris-aws-es-connection modified to work with the AWS Opensearch Service


AWS ES connection for the new opensearch client (@opensearch-project/opensearch)

## Usage
 Javascript:
```js
const { Client } = require('@opensearch-project/opensearch')
const { createAWSConnection, awsGetCredentials } = require('aws-opensearch-connection')

const awsCredentials = await awsGetCredentials()
const AWSConnection = createAWSConnection(awsCredentials)
const client = new Client({
  ...AWSConnection,
  node: 'https://node-name.eu-west-1.es.amazonaws.com'
})

// inside async func
await client.cat.help()
```

 Typescript:
```ts
import { createAWSConnection, awsGetCredentials } from 'aws-opensearch-connection'
import AWS from 'aws-sdk'
import { Client } from '@opensearch-project/opensearch'

const awsCredentials = await awsGetCredentials()
const AWSConnection = createAWSConnection(awsCredentials)
const client = new Client({
  ...AWSConnection,
  node: 'https://node-name.eu-west-1.es.amazonaws.com'
})

// inside async func
await client.cat.help()
```

## How does it work?
This package creates a Connection class that signs the requests to AWS elasticsearch and a Transport class that checks that the AWS credentials haven't expired before every call, and refreshes them when needed.

## Developer notes

### Running the tests.
Make sure that your AWS credentials are available to your env, for example you could set them in your ENV.

You need a running AWS ES instance for the tests to run against. Set the endpoint URL as the env `AWS_ES_ENDPOINT`.

```
AWS_ES_ENDPOINT=https://xxxx.es.amazonaws.com npm test
```
### Tested versions
This package has been tested on versions of the official elasticsearch client up to 7.13.0.

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