Skip to content

Commit ef17175

Browse files
committed
update README for v1.3.0
1 parent 163e016 commit ef17175

File tree

1 file changed

+71
-7
lines changed

1 file changed

+71
-7
lines changed

README.md

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ application development.
2727
- [Installation](#extensions-installation)
2828
- [Usage](#extensions-usage)
2929
- [About AddAwsService](#extensions-usage-about-addawsservice)
30+
- [useServiceUrl Parameter](#useserviceurl)
3031
- [Standalone Initialization](#standalone-initialization)
3132
- [Microsoft.Extensions.DependencyInjection Initialization](#di)
3233
5. [Developing](#developing)
@@ -129,7 +130,7 @@ You can configure `LocalStack.Client` by using entries in the `appsettings.json`
129130
"AwsAccessKeyId": "my-AwsAccessKeyId",
130131
"AwsAccessKey": "my-AwsAccessKey",
131132
"AwsSessionToken": "my-AwsSessionToken",
132-
"RegionName": null // can be values like "eu-central-1", "us-east-1", "us-west-1" etc.
133+
"RegionName": "eu-central-1"
133134
},
134135
"Config": {
135136
"LocalStackHost": "localhost",
@@ -145,9 +146,7 @@ So the above entries do not need to be specified.
145146

146147
What is entered for the aws credential values ​​in the `Session` section does not matter for LocalStack.
147148

148-
`RegionName` is important since LocalStack creates resources by spesified region (LocalStack has full multi-region support after `v0.12.17`). By default `RegionName` is `null`. If no value is entered in the `RegionName` entry, the [AWSSDK.NET](https://aws.amazon.com/sdk-for-net/) will use the `us-east-1` region by default.
149-
150-
<i><b>Internally depends on whether you set `RegionName` or not, the values of [ServiceUrl](https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/Amazon.Runtime/ClientConfig.cs#L202) ve [RegionEndpoint](https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/Amazon.Runtime/ClientConfig.cs#L144) properties of the [ClientConfig](https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/Amazon.Runtime/ClientConfig.cs) will change. [RegionEndpoint](https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/Amazon.Runtime/ClientConfig.cs#L144) and [ServiceUrl](https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/Amazon.Runtime/ClientConfig.cs#L202) are mutually exclusive properties. Whichever property is set last will cause the other to automatically be reset to null. If a value set to `RegionName` entry, the LocalStack.NET AWS will set RegionEndpoint property of the ClientConfig. Because of LocalStack.NET sets the RegionEndpoint property after the ServiceUrl property, ServiceUrl will be set to null.</b></i>
149+
<a name="session-regioname"></a>`RegionName` is important since LocalStack creates resources by spesified region.
151150

152151
`Config` section contains important entries for local development. Starting with LocalStack releases after `v0.11.5`, all services are now exposed via the edge service (port 4566) only! If you are using a version of LocalStack lower than v0.11.5, you should set `UseLegacyPorts` to `true`. Edge port can be set to any available port ([see LocalStack configuration section](https://github.com/localstack/localstack#configurations)). If you have made such a change in LocalStack's configuration, be sure to set the same port value to `EdgePort` in the `Config` section. For `LocalStackHost` and `UseSsl` entries, ​​corresponding to the [LocalStack configuration](https://github.com/localstack/localstack#configurations) should be used.
153152

@@ -190,6 +189,28 @@ It is named as `AddAwsService` to avoid name conflict with `AddAWSService`.
190189

191190
<e><b>(Alternatively, `AddAWSServiceLocalStack` method can be used to prevent mix-up with `AddAWSService`.)</b><e>
192191

192+
#### <a name="useserviceurl"></a> useServiceUrl Parameter
193+
194+
LocalStack.NET uses [ClientConfig](https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/Amazon.Runtime/ClientConfig.cs) to configure AWS clients to connect LocalStack. `ClientConfig` has two properties called `ServiceUrl` and `RegionEndpoint`, these are mutually exclusive properties. Whichever property is set last will cause the other to automatically be reset to null. LocalStack.NET has given priority to the RegionEndpoint property and the `us-east-1` region is used as the default value (Different regions can be set by using appsettings.json, see [RegionName](#session-regioname) entry. Because of it sets the RegionEndpoint property after the ServiceUrl property, ServiceUrl will be set to null.
195+
196+
To override this behavior, the `useServiceUrl` optional parameter can be set to `true` as below.
197+
198+
```csharp
199+
public void ConfigureServices(IServiceCollection services)
200+
{
201+
// Add framework services.
202+
services.AddMvc();
203+
204+
services.AddLocalStack(Configuration)
205+
services.AddDefaultAWSOptions(Configuration.GetAWSOptions());
206+
services.AddAwsService<IAmazonS3>();
207+
services.AddAwsService<IAmazonMediaStoreData>(useServiceUrl: true)
208+
services.AddAwsService<IAmazonIoTJobsDataPlane>(useServiceUrl: true)
209+
}
210+
```
211+
212+
The `RegionEndpoint` is not applicable for services such as AWS MediaStore, Iot. The optional parameter `useServiceUrl` can be useful for use in such scenarios.
213+
193214
### <a name="standalone-initialization"></a> Standalone Initialization
194215

195216
If you do not want to use any DI library, you have to instantiate `SessionStandalone` as follows.
@@ -200,7 +221,7 @@ If you do not want to use any DI library, you have to instantiate `SessionStanda
200221
* AwsAccessKeyId: accessKey (It doesn't matter to LocalStack)
201222
* AwsAccessKey: secretKey (It doesn't matter to LocalStack)
202223
* AwsSessionToken: token (It doesn't matter to LocalStack)
203-
* RegionName: null // can be values like "eu-central-1", "us-east-1", "us-west-1" etc.
224+
* RegionName: us-east-1
204225
* ==== Custom Values ====
205226
* var sessionOptions = new SessionOptions("someAwsAccessKeyId", "someAwsAccessKey", "someAwsSessionToken", "eu-central-");
206227
*/
@@ -230,6 +251,32 @@ var amazonS3Client = session.CreateClientByImplementation<AmazonS3Client>();
230251
var amazonS3Client = session.CreateClientByInterface<IAmazonS3>();
231252
```
232253

254+
### <a name="standalone-useserviceurl"></a><b>useServiceUrl Parameter</b>
255+
256+
LocalStack.NET uses [ClientConfig](https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/Amazon.Runtime/ClientConfig.cs) to configure AWS clients to connect LocalStack. `ClientConfig` has two properties called `ServiceUrl` and `RegionEndpoint`, these are mutually exclusive properties. Whichever property is set last will cause the other to automatically be reset to null. LocalStack.NET has given priority to the RegionEndpoint property and the `us-east-1` region is used as the default value (Different regions can be set by using appsettings.json, see [RegionName](#session-regioname) entry. Because of it sets the RegionEndpoint property after the ServiceUrl property, ServiceUrl will be set to null.
257+
258+
To override this behavior, the `useServiceUrl` optional parameter can be set to `true` as below.
259+
260+
```csharp
261+
var sessionOptions = new SessionOptions();
262+
var configOptions = new ConfigOptions();
263+
264+
ISession session = SessionStandalone.Init()
265+
.WithSessionOptions(sessionOptions)
266+
.WithConfigurationOptions(configOptions).Create();
267+
268+
var amazonS3Client = session.CreateClientByImplementation<AmazonMediaStoreDataClient>(true);
269+
var amazonS3Client = session.CreateClientByImplementation<AmazonS3Client>();
270+
```
271+
272+
The `RegionEndpoint` is not applicable for services such as AWS MediaStore, Iot. The optional parameter `useServiceUrl` can be useful for use in such scenarios.
273+
274+
`CreateClientByInterface<TSerice>` method can also be used to create AWS service, as follows
275+
276+
```csharp
277+
var amazonS3Client = session.CreateClientByInterface<IAmazonMediaStoreData>(true);
278+
```
279+
233280
### <a name="di"></a> Microsoft.Extensions.DependencyInjection Initialization
234281

235282
First, you need to install `Microsoft.Extensions.DependencyInjection` nuget package as follows
@@ -248,7 +295,7 @@ var collection = new ServiceCollection();
248295
* AwsAccessKeyId: accessKey (It doesn't matter to LocalStack)
249296
* AwsAccessKey: secretKey (It doesn't matter to LocalStack)
250297
* AwsSessionToken: token (It doesn't matter to LocalStack)
251-
* RegionName: null // can be values like "eu-central-1", "us-east-1", "us-west-1" etc.
298+
* RegionName: us-east-1
252299
* ==== Custom Values ====
253300
* var sessionOptions = new SessionOptions("someAwsAccessKeyId", "someAwsAccessKey", "someAwsSessionToken", "eu-central-");
254301
*/
@@ -303,7 +350,7 @@ collection.Configure<LocalStackOptions>(options => configuration.GetSection("Loc
303350
* AwsAccessKeyId: accessKey (It doesn't matter to LocalStack)
304351
* AwsAccessKey: secretKey (It doesn't matter to LocalStack)
305352
* AwsSessionToken: token (It doesn't matter to LocalStack)
306-
* RegionName: null // can be values like "eu-central-1", "us-east-1", "us-west-1" etc.
353+
* RegionName: us-east-1
307354
*/
308355
collection.Configure<SessionOptions>(options => configuration.GetSection("LocalStack")
309356
.GetSection(nameof(LocalStackOptions.Session))
@@ -347,6 +394,8 @@ ServiceProvider serviceProvider = collection.BuildServiceProvider();
347394
var amazonS3Client = serviceProvider.GetRequiredService<IAmazonS3>();
348395
```
349396

397+
See [useServiceUrl] parameter usage (#standalone-useserviceurl)
398+
350399
## <a name="developing"></a> Developing
351400

352401
We welcome feedback, bug reports, and pull requests!
@@ -391,6 +440,21 @@ Linux
391440

392441
## <a name="changelog"></a> Changelog
393442

443+
### [v1.3.0](https://github.com/localstack-dotnet/localstack-dotnet-client/releases/tag/v1.3.0)
444+
445+
#### 1. New Features
446+
- New endpoints in the official [Localstack Python Client](https://github.com/localstack/localstack-python-client) v1.27 have been added.
447+
- SESv2
448+
- EventBridge ([#14](https://github.com/localstack-dotnet/localstack-dotnet-client/pull/14))
449+
- Tested against LocalStack v0.13.0 container.
450+
#### 2. Enhancements
451+
- `useServiceUrl` parameter added to change client connection behavior. See [useServiceUrl Parameter](#useserviceurl)
452+
- Readme and SourceLink added to Nuget packages
453+
#### 3. Bug Fixes
454+
- Session::RegionName configuration does not honor while creating AWS client ([#15](https://github.com/localstack-dotnet/localstack-dotnet-client/issues/15))
455+
456+
Thanks to [petertownsend](https://github.com/petertownsend) for his contribution
457+
394458
### [v1.2.3](https://github.com/localstack-dotnet/localstack-dotnet-client/releases/tag/v1.2.3)
395459

396460
- New endpoints in the official [Localstack Python Client](https://github.com/localstack/localstack-python-client) v1.25 have been added.

0 commit comments

Comments
 (0)