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

Using with Secured Elastic Search #43

Closed DedicatedManagers closed 5 years ago

DedicatedManagers commented 5 years ago

How would I go about implementing the credentials if I were to secure my elastic search via IAM (as in this video https://youtu.be/iunkVDfZZXQ ). We are using dotnet core 2.2

bcuff commented 5 years ago

If you supply credentials to your application in any of the standard ways (ec2 instance profile role, environment variables, or aws cli profile) this library should pick up those credentials and use them automatically.

DedicatedManagers commented 5 years ago

Thanks for the reply!

I'm new to dotnet & C#, so I'd greatly appreciate if you could point me in the direction how to implement the ec2 instance profile role credentials in dotnet.

Ist this the right direction? https://docs.aws.amazon.com/sdk-for-net/v2/developer-guide/net-dg-config-creds.html

Also, Will it pick up AWS4Signer? Or is this a function to add a header to a request that has the right tokens/credentials?

https://github.com/aws/aws-sdk-net/blob/6c3be79bdafd5bfff1ab0bf5fec17abc66c7b516/sdk/src/Core/Amazon.Runtime/Internal/Auth/AWS4Signer.cs

Sign(IRequest request, ClientConfig clientConfig,RequestMetrics metrics, string awsAccessKeyId, string awsSecretAccessKey)

bcuff commented 5 years ago

If you are running your code on an EC2 instance you can assign an IAM instance profile to that instance. Then the client will automatically pick up credenetials from there. If you're running on lambda the situation is similar. No need to configure credentials in both of those cases. You only need to specify the region.

bcuff commented 5 years ago

I'm going to close this since I haven't heard back from you. If you still have questions feel free to re-open the issue.