Question: I am trying to work out how to use/access the IAM role credentials on an windows ec2 instance when running a dotnetcore webapi on IIS.

I know that when running a dotnetcore app on ec2 linux the credentials are available to the default constructors but this does not seem to be the case when running on IIS, is there are particular instantiation method to use or does the IIS/kestrel server not have access to the credentials?

Thank you

Answer: 
To answer my own question:

1. Use a default constructor like `var s3Client = new AmazonS3Client();`
2. Yes, the Kestrel server does have RBAC access.

Further information:

The best practice for instantiating an Amazon client is to use the default constructor as above.

I had previously read people having issues accessing credentials while using .NET Core on IIS as the app runs on Kestrel server, but on EC2 instances the client still has access to the role-based access credentials. When running on EC2 Servers is a bad practice to have credentials written on the server, which is what almost every IIS question/answer thread pose as a solution and that is correct if IIS is not on an AWS server.
There are a number of ways to provide AWS credentials to your .NET applications. One approach is to embed your credentials in the appSettings sections of your App.config file:

```
<configuration>
   <appSettings>
      <add key="AWSProfileName" value="development"/>
      <add key="AWSRegion" value="us-west-2" />
   </appSettings>
</configuration>

```

For more information about it, you can refer to this [link](https://aws.amazon.com/cn/blogs/developer/referencing-credentials-using-profiles/).

There is a similar question on SO, you also can refer to [it](https://stackoverflow.com/questions/25560545/aws-sdk-for-net-cant-access-credentials-with-iis).