bcuff / elasticsearch-net-aws

Add-on to Elasticsearch.Net & NEST for using AWS's elasticsearch service.
Apache License 2.0
72 stars 27 forks source link

How do I create a client with the V4 Signing process #44

Closed NRKirby closed 5 years ago

NRKirby commented 5 years ago

Hi, I was wondering if you could help me create a client that is signed with the V4 signing process?

I am using NEST v 6.6.0 and I've installed the Elasticsearch.Net.Aws package but I'm not sure how I create a client with my credentials.

The example for Elasticsearch.Net Version >= 2.0.2 on the README doesn't show how to create the client with any kind of credentials/access key/secret.

Any help would be really appreciated, thanks!

bcuff commented 5 years ago

If you must supply an access key explicitly you can use this constructor. However I recommend supplying credentials to your application via EC2 instance profile or other means. See this guide for more information.

This library uses the AWSSDK's normal means of loading credentials and should work just like other service clients in that library. If you don't supply credentials then it will try to look them up automatically via environment variables, aws profile, and ec2 instance metadata.

NRKirby commented 5 years ago

Thanks for replying so quickly.

I should have said I'm using the AWS Elastic Search service - does this matter?

I have an access policy allowing a particular account (my account) and I'm unsure whether I have to provide my username and password, or whether I need to create an access key/secret?

Thanks again

bcuff commented 5 years ago

It depends on where you're running your code. If you are going to run on an EC2 instance you can simply assign a role that has access to your Elasticsearch Service domain to the EC2 instance. The same goes for running on AWS Lambda. If you're running from your local computer then you will need to use an access key. You can supply the access key to your application in few different ways described in this guide

NRKirby commented 5 years ago

I am going to be calling the Elasticsearch service from Azure functions so I think I'll need to use the constructor.

I just had a look at the documentation but it's not clear how I should create the credentials for my use case.

Edit: I just found this document which shows AWSCredentials subclasses

bcuff commented 5 years ago

If you're using Azure this library won't work for. This will only work for Amazon AWS.

NRKirby commented 5 years ago

Thanks for letting me know -I didn't know that and should have mentioned Azure sooner...

bcuff commented 5 years ago

You're welcome.