Skip to content

Commit

Permalink
add S3 note for .NET SDK (#521)
Browse files Browse the repository at this point in the history
* add S3 note for .NET SDK

* add sentence
  • Loading branch information
bentsku committed Mar 17, 2023
1 parent 32a42f2 commit c4cce19
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions content/en/user-guide/integrations/sdks/dotnet/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,51 @@ which is the preferred way of integrating the .NET SDK with LocalStack.
Here is an example of how to create an `LambdaClient` with the endpoint set to LocalStack.

```csharp
var lambdaClient = new AmazonLambdaClient(new AmazonLambdaConfig()
var lambdaClient = new AmazonLambdaClient(new AmazonLambdaConfig(
{
ServiceURL = "http://localhost:4566"
});
}
);
```

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

```csharp
var lambdaClient = new AmazonLambdaClient(new BasicAWSCredentials("temp", "temp"), new AmazonLambdaConfig()
var lambdaClient = new AmazonLambdaClient(new BasicAWSCredentials("test", "test"), new AmazonLambdaConfig(
{
ServiceURL = "http://localhost:4566",
AuthenticationRegion = "eu-west-1"
});
}
);
```

{{< alert title="Note">}}
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.
{{< /alert >}}

### S3 specific endpoint

Here is another example, this time with an `S3Client` and its specific endpoint.

```csharp
var config = new AmazonS3Config({ ServiceURL = "http://s3.localhost.localstack.cloud:4566" });
var s3client = new AmazonS3Client(config);
```

{{< alert title="Note">}}
In case of issues resolving this DNS record, we can fallback to http://localhost:4566 in combination with the provider setting `ForcePathStyle = true`. The S3 service endpoint is slightly different from the other service endpoints, because AWS is deprecating path-style based access for hosting buckets.
{{< /alert >}}

```csharp
var config = new AmazonS3Config(
{
ServiceURL = "http://localhost:4566",
ForcePathStyle = true
}
);
var s3client = new AmazonS3Client(config);
```

## Resources

Expand Down

0 comments on commit c4cce19

Please sign in to comment.