Git Product home page Git Product logo

aws-elasticsearch-connector's Introduction

aws-elasticsearch-connector

Build Status Code Climate Test Coverage Dependency Status Download Status

A tiny Amazon Signature Version 4 connection class for the official Elasticsearch Node.js client, for compatibility with AWS Elasticsearch and IAM authentication.

For legacy Elasticsearch.js 16.x support, use version 7.x of this library.

Installation

npm install --save aws-elasticsearch-connector @elastic/elasticsearch aws-sdk

Example usage

With static credentials

const { Client } = require('@elastic/elasticsearch');
const { AmazonConnection } = require('aws-elasticsearch-connector');

const client = new Client({
  node: 'my-elasticsearch-cluster.us-east-1.es.amazonaws.com',
  Connection: AmazonConnection,
  awsConfig: {
    credentials: {
      accessKeyId: 'foo',
      secretAccessKey: 'bar',
      sessionToken: 'baz' // optional
    }
  }
});

With static credentials from AWS.Config

const AWS = require('aws-sdk');
const { Client } = require('@elastic/elasticsearch');
const { AmazonConnection } = require('aws-elasticsearch-connector');

// Load AWS profile credentials
AWS.config.update({
  profile: 'my-profile'
});

const client = new Client({
  node: 'my-elasticsearch-cluster.us-east-1.es.amazonaws.com',
  Connection: AmazonConnection
});

With static credentials from the environment

AWS_ACCESS_KEY_ID=foo      # alias: AWS_ACCESS_KEY
AWS_SECRET_ACCESS_KEY=bar  # alias: AWS_SECRET_KEY
AWS_SESSION_TOKEN=baz
const { Client } = require('@elastic/elasticsearch');
const { AmazonConnection } = require('aws-elasticsearch-connector');

const client = new Client({
  node: 'my-elasticsearch-cluster.us-east-1.es.amazonaws.com',
  Connection: AmazonConnection,
});

With asynchronous or refreshing credentials from AWS

When reading AWS credentials from an IAM role or an EC2/ECS profile, the credentials will be retrieved and refreshed automatically. In this case you'll need to use the bundled AmazonTransport transport which will call AWS.Config.getCredentials() before each ElasticSearch request to ensure that the latest credentials are used.

const { Client } = require('@elastic/elasticsearch');
const { AmazonConnection, AmazonTransport } = require('aws-elasticsearch-connector');

const client = new Client({
  node: 'my-elasticsearch-cluster.us-east-1.es.amazonaws.com',
  Connection: AmazonConnection,
  Transport: AmazonTransport
});

Test

npm test

# Run integration tests against a real endpoint
AWS_PROFILE=your-profile npm run test:integration -- \
  --endpoint https://amazon-es-host.us-east-1.es.amazonaws.com

aws-elasticsearch-connector's People

Contributors

buildbreakdo avatar compwright avatar dougmoscrop avatar ef4 avatar improved-broccoli avatar laurie-qlik avatar nathanmoon avatar subodhkhanduri1 avatar thedeveloper avatar umberto-sonnino avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.