From 22a7ff4ae3d4fd21512693da5c42256b10446c10 Mon Sep 17 00:00:00 2001 From: Brandon Cuff Date: Wed, 13 Nov 2019 15:09:25 -0800 Subject: [PATCH] Version 7.0.3 - AWSOptions setup --- README.md | 31 +++++++++++++------ .../AwsHttpConnection.cs | 10 ++++++ .../Elasticsearch.Net.Aws.csproj | 16 ++++++---- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f8ebbe4..ba781d1 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ Add-on to [elasticsearch-net / NEST](https://github.com/elastic/elasticsearch-net) for using AWS's elasticsearch service. ## Install Package -On Nuget + +On Nuget: + * [Current Version 5.0+](https://www.nuget.org/packages/Elasticsearch.Net.Aws/) * [NEST / Elasticsearch.Net 2.X](https://www.nuget.org/packages/bcuff.Elasticsearch.Net.Aws-v2/) * [NEST / Elasticsearch.Net 1.X](https://www.nuget.org/packages/Elasticsearch.Net.Aws-v1/) @@ -27,26 +29,37 @@ dotnet add package Elasticsearch.Net.Aws-v1 ## Setup -#### Elasticsearch.Net Version >= 2.0.2 +### Elasticsearch.Net Version >= 2.0.2 -**Use Package Elasticsearch.Net.Aws** +Use Package [Elasticsearch.Net.Aws](https://www.nuget.org/packages/Elasticsearch.Net.Aws/). + +#### Typical Setup ```csharp // for NEST -// if using app.config, environment variables, or roles // This constructor will look up AWS credentials in the // same way that the AWSSDK does automatically. -var httpConnection = new AwsHttpConnection("us-east-1"); +var httpConnection = new AwsHttpConnection(); var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200")); var config = new ConnectionSettings(pool, httpConnection); var client = new ElasticClient(config); ``` +#### .NET Core Applications using IConfiguration + +```csharp +IConfiguration config = Configuration; +var options = config.GetAWSOptions(); +var httpConnection = new AwsHttpConnection(options); + +// same as above +``` + #### Elasticsearch.Net Version 1.7.1 -**Use Package Elasticsearch.Net.Aws-v1** +Use Package [Elasticsearch.Net.Aws-v1](https://www.nuget.org/packages/Elasticsearch.Net.Aws-v1) Source for this version is maintained on the version-1 branch @@ -54,9 +67,9 @@ Source for this version is maintained on the version-1 branch // for NEST var client = new ElasticClient(settings, connection: new AwsHttpConnection(settings, new AwsSettings { - AccessKey = "My AWS access key", - SecretKey = "My AWS secret key", - Region = "us-east-1", + AccessKey = "My AWS access key", + SecretKey = "My AWS secret key", + Region = "us-east-1", })); ``` diff --git a/src/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws/AwsHttpConnection.cs b/src/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws/AwsHttpConnection.cs index 857f513..4ad018c 100644 --- a/src/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws/AwsHttpConnection.cs +++ b/src/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws/AwsHttpConnection.cs @@ -4,6 +4,9 @@ using System.Net.Http; using Amazon; using Amazon.Runtime; +#if NETSTANDARD +using Amazon.Extensions.NETCore.Setup; +#endif namespace Elasticsearch.Net.Aws { @@ -15,6 +18,13 @@ public class AwsHttpConnection : HttpConnection private readonly AWSCredentials _credentials; private readonly RegionEndpoint _region; +#if NETSTANDARD + public AwsHttpConnection(AWSOptions options) + : this(options.Credentials, options.Region) + { + } +#endif + /// /// Initializes a new instance of the AwsHttpConnection class with the specified AccessKey, SecretKey and Token. /// diff --git a/src/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws.csproj b/src/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws.csproj index 1fc37e3..dd6e51c 100644 --- a/src/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws.csproj +++ b/src/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws.csproj @@ -1,22 +1,22 @@  - 7.0.2 + 7.0.3 netstandard2.0;net461 Elasticsearch.Net.Aws Elasticsearch.Net.Aws - 7.0.2 + 7.0.3 Brandon Cuff Enables request signing necessary for using the AWS Elasticsearch service. Copyright 2015 https://raw.githubusercontent.com/bcuff/elasticsearch-net-aws/master/LICENSE https://github.com/bcuff/elasticsearch-net-aws - Support NET Framework 4.6.1 + Added AWSOptions overload. elasticsearch elastic search aws amazon https://github.com/bcuff/elasticsearch-net-aws - 7.0.2 - 7.0.2 - 7.0.2 + 7.0.3 + 7.0.3 + 7.0.3 @@ -25,6 +25,10 @@ true + + + +