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

Examples of using AWS SDK Core to get credentials? #41

Closed lorenh closed 5 years ago

lorenh commented 5 years ago

I apologize if this is a silly question but, what's the equivalent in version 6.1.0 for the following code? (which no longer compiles)

var instanceProfileCredentialProvider = new InstanceProfileCredentialProvider();

var httpConnection = new AwsHttpConnection("us-east-1", instanceProfileCredentialProvider);

lorenh commented 5 years ago

I apologize, I should have hammered at it a little longer before I posted. I think it might be something like this. (Although I haven't tested it on a server in AWS yet)

using Amazon; using Amazon.Runtime; :

var instanceProfileCredentialProvider = new InstanceProfileAWSCredentials(); var httpConnection = new AwsHttpConnection(instanceProfileCredentialProvider, RegionEndpoint.USEast1);

bcuff commented 5 years ago

Yes, that looks right. You might want to just use the overload that doesn't provide credentials though:

var httpConnection = new AwsHttpConnection("us-east-1");

This will just use Amazon's default credential probing behavior which looks for environment variables, aws profile configuration, and instance profile credentials.

See this constructor

lorenh commented 5 years ago

The overload you suggested works just fine. Thanks