From dc09ea070da223160ed08fcdfcdbfde9915db703 Mon Sep 17 00:00:00 2001 From: Theo Nam Truong Date: Mon, 5 Dec 2022 11:16:34 -0700 Subject: [PATCH] Added doc for Ruby Sigv4 (#2089) * Added doc for Ruby Sigv4 Signed-off-by: Theo Truong * Update _clients/ruby.md Style update Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Signed-off-by: Theo Truong Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> --- _clients/ruby.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/_clients/ruby.md b/_clients/ruby.md index 34167907..9ecbd178 100644 --- a/_clients/ruby.md +++ b/_clients/ruby.md @@ -525,4 +525,26 @@ puts 'Deleting the index:' response = client.indices.delete(index: index_name) puts MultiJson.dump(response, pretty: "true") -``` \ No newline at end of file +``` + +# Ruby AWS Sigv4 Client + +The [opensearch-aws-sigv4](https://github.com/opensearch-project/opensearch-ruby/tree/main/opensearch-aws-sigv4) gem provides the `OpenSearch::Aws::Sigv4Client` class, which has all features of `OpenSearch::Client`. The only difference between these two clients is that `OpenSearch::Aws::Sigv4Client` requires an instance of `Aws::Sigv4::Signer` during instantiation to authenticate with AWS: + +```ruby +require 'opensearch-aws-sigv4' +require 'aws-sigv4' + +signer = Aws::Sigv4::Signer.new(service: 'es', + region: 'us-west-2', + access_key_id: 'key_id', + secret_access_key: 'secret') + +client = OpenSearch::Aws::Sigv4Client.new({ log: true }, signer) + +client.cluster.health + +client.transport.reload_connections! + +client.search q: 'test' +```