包详细信息

aws-elasticsearch-connector

compwright130.3kMIT9.2.0

A tiny Amazon Signature Version 4 connection class for @elastic/elasticsearch, for compatibility with AWS Elasticsearch and IAM authentication.

elasticsearch, aws-es, aws, aws4

自述文件

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.

Supports AWS SDK global or specific configuration instances (AWS.Config), including asyncronous credentials from IAM roles and credential refreshing.

Installation

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

Example usage

Using global configuration

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

// (Optional) load profile credentials from file
AWS.config.update({
  profile: "my-profile",
});

const client = new Client({
  ...createAwsElasticsearchConnector(AWS.config),
  node: "https://my-elasticsearch-cluster.us-east-1.es.amazonaws.com",
});

Using specific configuration

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

const awsConfig = new AWS.Config({
  // Your credentials and settings here, see
  // https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#constructor-property
});

const client = new Client({
  ...createAwsElasticsearchConnector(awsConfig),
  node: "https://my-elasticsearch-cluster.us-east-1.es.amazonaws.com",
});

Using aws-sdk v3

const { STSClient, AssumeRoleCommand } = require("@aws-sdk/client-sts");
const { Client } = require("@elastic/elasticsearch");
const createAwsElasticsearchConnector = require("./src/index.js");

async function ping() {
  const creds = await assumeRole(
    "arn:aws:iam::0123456789012:role/Administrator",
    "us-east-1"
  );
  const client = new Client({
    ...createAwsElasticsearchConnector({
      region: "us-east-1",
      credentials: creds,
    }),
    node: "https://my-elasticsearch-cluster.us-east-1.es.amazonaws.com",
  });
  const response = await client.ping();
  console.log(`Got Response`, response);
}

async function assumeRole(roleArn, region) {
  const client = new STSClient({ region });
  const response = await client.send(
    new AssumeRoleCommand({
      RoleArn: roleArn,
      RoleSessionName: "aws-es-connection",
    })
  );
  return {
    accessKeyId: response.Credentials.AccessKeyId,
    secretAccessKey: response.Credentials.SecretAccessKey,
    sessionToken: response.Credentials.SessionToken,
  };
}

Test

npm test

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

更新日志

Changelog

v9.0.3 (2021-01-23)

Full Changelog

Closed issues:

  • AWS ElasticSearch Custom domain names not connecting #24
  • aws sigv4 signature not match when Content-Length exist in the request before applying AmazonConnection #22

Merged pull requests:

  • Set region when signing request if provided in the AWS config object #26 (chsing-br)

v9.0.1 (2020-11-17)

Full Changelog

Closed issues:

  • Setting AWS.Config httpOptions does not work #23

Merged pull requests:

  • Add support for elasticSearch 6.x branch #20 (osdroid)

v9.0.0 (2020-07-04)

Full Changelog

v8.3.0 (2020-07-04)

Full Changelog

Merged pull requests:

v8.2.0 (2019-10-25)

Full Changelog

Fixed bugs:

  • The request signature we calculated does not match the signature you provided #4
  • Support for IAM Roles? #3

Merged pull requests:

  • Handle refreshed credentials when running in ECS or EC2 #5 (nathanmoon)

v8.1.3 (2019-09-04)

Full Changelog

v8.1.2 (2019-09-03)

Full Changelog

v8.1.1 (2019-08-31)

Full Changelog

v8.1.0 (2019-08-31)

Full Changelog

Merged pull requests:

  • Use config instead of credentials as a field and specify 'es' as the service for this request #2 (umberto-sonnino)

v8.0.0 (2019-08-17)

Full Changelog

v7.0.0 (2019-08-16)

Full Changelog

v6.0.0 (2018-05-19)

Full Changelog

v4.0.0 (2017-11-25)

Full Changelog

v3.1.3 (2017-10-22)

Full Changelog

v3.1.2 (2017-10-22)

Full Changelog

v3.1.1 (2017-10-21)

Full Changelog

v3.1.0 (2017-08-25)

Full Changelog

v3.0.0 (2017-08-25)

Full Changelog

v2.0.5 (2017-07-30)

Full Changelog

v2.0.4 (2017-07-12)

Full Changelog

v2.0.3 (2017-06-20)

Full Changelog

v2.0.0 (2017-06-20)

Full Changelog

v1.1.3 (2015-12-01)

Full Changelog

v1.1.2 (2015-10-27)

Full Changelog

v1.1.1 (2015-10-19)

Full Changelog

v1.1.0 (2015-10-19)

Full Changelog

v1.0.2 (2015-10-04)

Full Changelog

v1.0.1 (2015-10-04)

Full Changelog

* This Changelog was automatically generated by github_changelog_generator