.NET

How to use the .NET AWS SDK with LocalStack.

Overview

The AWS SDK for .NET, like other AWS SDKs, lets you set the endpoint when creating resource clients, which is the preferred way of integrating the .NET SDK with LocalStack.

Example

Here is an example of how to create an LambdaClient with the endpoint set to LocalStack.

  1. var lambdaClient = new AmazonLambdaClient(new AmazonLambdaConfig()
  2. {
  3. ServiceURL = "http://localhost:4566"
  4. });

If you want to specify a region and credentials when creating the client, please set them as AuthenticationRegion and BasicAWSCredentials, like in this example:

  1. var lambdaClient = new AmazonLambdaClient(new BasicAWSCredentials("temp", "temp"), new AmazonLambdaConfig()
  2. {
  3. ServiceURL = "http://localhost:4566",
  4. AuthenticationRegion = "eu-west-1"
  5. });

Make sure you are setting the AuthenticationRegion and not the RegionEndpoint. Setting the RegionEndpoint to a constant like RegionEndpoint.EUWest1 will override the ServiceURL, and your request will end up against AWS.

Resources

Last modified June 10, 2022: add docs for .NET SDK (#180) (f6524506)