@smidges/aws-es-connection
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

aws-es-connection

Purpose

When restricting AWS Elasticsearch to an IAM user/role, requests need to be signed to be accepted.

There is an outdated connection package for the legacy elasticsearch client, but there is no packaged for for the newewst @elastic/elasticsearch client, until now.

This is based on code provided in an issue on the client's repo. I adapted the example to be used from an npm package.

Usage

Install

npm i @smidges/aws-es-connection

Peer Dependencies

You must install these packages along side as they will not be included by default.

npm install aws-sdk @elastic/elasticsearch

Region

AWS Region has to be defined in order to sign the requests.

Either AWS.config.region or process.env.AWS_DEFAULT_REGION should be set to the region of choice.

Credentials

The package assumes AWS.config.credentials is configured already with the correct role needed to access Elasticsearch.

import { Client, Connection } from '@elastic/elasticsearch';
import { AwsSignedConnection } from '@smidges/aws-es-connection';
import * as AWS from 'aws-sdk';


const client = new Client({
  node: 'https://<unique-url>.us-east-1.es.amazonaws.com',
  Connection: AWS.config.credentials ? AwsSignedConnection : Connection,
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    74
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    74

Package Sidebar

Install

npm i @smidges/aws-es-connection

Weekly Downloads

74

Version

1.0.0

License

MIT

Unpacked Size

6.14 kB

Total Files

5

Last publish

Collaborators

  • smidges