3

We are using elasticsearch-rest-high-level-client to communicate with AWS Elasticsearch.

But, as we are told, we need to sign requests with AWS credentials. I am aware of the class AWS4Signer, but don't know how can I use it with elasticsearch-rest-high-level-client.

halfer
  • 19,824
  • 17
  • 99
  • 186
Prakhar Mishra
  • 1,586
  • 4
  • 28
  • 52
  • 1
    This should get you going: https://stackoverflow.com/questions/33760144/signing-aws-http-requests-with-apache-httpcomponents-client – Val Apr 10 '18 at 07:19

2 Answers2

0

From the aws documentation

public static RestHighLevelClient esClient(String serviceName, String region) {
    AWS4Signer signer = new AWS4Signer();
    signer.setServiceName(serviceName);
    signer.setRegionName(region);
    HttpRequestInterceptor interceptor = new AWSRequestSigningApacheInterceptor(serviceName, signer, credentialsProvider);
    return new RestHighLevelClient(RestClient.builder(HttpHost.create(aesEndpoint)).setHttpClientConfigCallback(hacb -> hacb.addInterceptorLast(interceptor)));
}
bstent
  • 95
  • 1
  • 8
0

There's a new maintained fork of the archived aws-request-signing-apache-interceptor. It was upgraded to AWS SDK 2, and has a number of bug fixes, such as supporting retries. It contains a working example of how to talk to Amazon OpenSearch (Elasticsearch). Version 2.1.1 was just released to Maven central.

dB.
  • 4,700
  • 2
  • 46
  • 51