4

I need to sign requests to Opensearch. I'm attempting to use opensearch-js and aws-es-connection to do that.

import {
  createAWSConnection,
  awsGetCredentials,
} from '@acuris/aws-es-connection';
import { Client } from "@opensearch-project/opensearch";
import { esConfig } from "./config";

export const getClient = async () => {
  const awsCredentials = await awsGetCredentials();
  const AWSConnection = createAWSConnection(awsCredentials);
  const client = new Client({
    ...AWSConnection,
    node: esConfig.uri
  });
  return client;
};

However, this code complains about the types not being compatible with the destructure ... syntax.

S2345: Argument of type '{ node: string; nodes?: string | string[] | NodeOptions | NodeOptions[]; Connection?: typeof Connection; ConnectionPool?: typeof ConnectionPool; ... 26 more ...; caFingerprint?: string; }' is not assignable to parameter of type 'ClientOptions'.   Types of property 'ConnectionPool' are incompatible.     Type 'typeof import("/packages/api/node_modules/@elastic/elasticsearch/lib/pool/index").ConnectionPool' is not assignable to type 'typeof import("/packages/api/node_modules/@opensearch-project/opensearch/lib/pool/index").ConnectionPool'.       Types of parameters 'opts' and 'opts' are incompatible.
...

Perhaps I'm making a dumb mistake with the destructuring? Is there another way of signing requests for opensearch-js?

Val
  • 207,596
  • 13
  • 358
  • 360
conner.xyz
  • 6,273
  • 8
  • 39
  • 65

0 Answers0