title: AWS .NET SDK configure S3 Client with ASP.NET Core Dependency Injection
body: <p><strong>Tools</strong></p>
  
  <ul>
  <li>Visual Studio 2017 Professional</li>
  <li>.NET Core SDK v2.2.102</li>
  <li>AWSSDK.S3 v3.3.102.14</li>
  </ul>
  
  <p><strong>What I'm trying to do</strong></p>
  
  <p>Configure the Amazon S3 client for a development environment which uses a localstack endpoint as the ServiceURL for S3</p>
  
  <p>I'm trying to configure the S3 client globally in my <code>Startup.cs</code> file using ASP.NET Core's native Dependency Injection</p>
  
  <pre class="lang-cs prettyprint-override"><code>public void ConfigureServices(IServiceCollection services)
  {
      ...
  
      services.AddAWSService&lt;IAmazonS3&gt;();
  }
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>I can't figure out how to set the ServiceURL for the S3 Client.  I've seen in the <a href="https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-config-netcore.html" rel="nofollow noreferrer">AWS documentation</a> that you can configure this property in the the <code>appsettings.json</code> file.  However, this wouldn't resolve my problem because I have multiple AWS services I need to integrate with.</p>
  
  <p>Everything I've googled suggests you just need to do something like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var s3Client = new AmazonS3Client(new AmazonS3Config
  {
      ServiceURL = "http://localhost:5002"
  });
  </code></pre>
  
  <p>But I would have to do this in every class that uses the S3 client, which doesn't seem right.</p>
  
  <p>Any help is appreciated.  Thanks</p>