4

I am trying to write a lambda to get data from OpenSearach domain.

const { Client } = require('@opensearch-project/opensearch');
const { createAWSConnection, awsGetCredentials } = require('@acuris/aws-es-connection');

const test = async () => {

    const awsCredentials = await awsGetCredentials();
    const AWSConnection = createAWSConnection(awsCredentials);
    const client = new Client({
        ...AWSConnection,
        node: 'https://<domain-name>.us-east-2.es.amazonaws.com'
    });

    // inside async func
    await client.cat.help();
};
test();

Error:

(node:32926) ProductNotSupportedSecurityError: The client is unable to verify that the server is Elasticsearch due to security privileges on the server-side. Some functionality may not be compatible if the server is running an unsupported product.
kumarahul
  • 396
  • 4
  • 10
  • Have you found a solution to this? – D_Edet Dec 29 '21 at 10:11
  • I haven't tested any of the answers yet, working with rest apis for now... – kumarahul Dec 30 '21 at 16:22
  • Okay. Did you try creating a user on AWS and adding that user to a group that has aws elasticsearch access policy? That's the right credential to use. – D_Edet Dec 30 '21 at 17:53
  • If u r using fine-grained access control u can refer to this blog: https://www.antstack.io/blog/getting-started-with-open-search or for regular access yes, IAM permissions would work, – kumarahul Jan 02 '22 at 14:59

2 Answers2

0

I faced with the same error but I used @elasticsearch lib instead of @opensearch-project. Maybe you can try it too. Error was resolved by downgrading @elasticsearch lib version.

Arthur Sg
  • 1
  • 1
0

Try using the Elasticsearch client version 7.13.0. According to the docs, it is the latest Elasticsearch client that is compatible with OpenSearch.

svorcan
  • 340
  • 1
  • 11