title: How to upload a file to AWS S3 without access key & secret key
body: <p>Before I begin, I have already read <a href="https://stackoverflow.com/questions/9278437/uploading-to-amazon-s3-without-access-secret-key">SO post</a> related to same question. However the SDK version in that post is old.
  As per <a href="http://www.nuget.org/profiles/awsdotnet" rel="nofollow noreferrer">AWS nugetpage</a> there is new version 3 is available which has separate packages for each service.</p>
  
  <blockquote>
    <p>The new version 3 of the AWS SDK for .NET uses separate packages for
    each service. For example Amazon S3 is in the AWSSDK.S3 package,
    Amazon SQS is in AWSSDK.SQS and Amazon DynamnoDB is in
    AWSSDK.DynamoDBv2.</p>
  </blockquote>
  
  <p>So i have installed <code>AWSSDK.S3</code> package from nuget which also installs dependency <code>AWSSDK.Core</code>. 
  The bucket im using is restricted using IP, so machine where im executing code has full access to the bucket.</p>
  
  <p>Below is my code to upload a file to S3.  However im getting exception when i create new instance of <code>AmazonS3Client</code> using <code>new AmazonS3Client(RegionEndpoint.USWest2);</code></p>
  
  <p>again note that i am getting exception is while creating the instance not while uploading the file.</p>
  
  <pre><code> var s3Client = new AmazonS3Client(RegionEndpoint.USWest2);  //exception at this line
  
   var bucketName = "mybucketname";
    PutObjectRequest putRequest1 = new PutObjectRequest
    {
                  BucketName = bucketName,
                  Key = "MyKey/test1.pdf",
                  FilePath = filePath
    };
  
    PutObjectResponse response1 = s3Client.PutObject(putRequest1);
  </code></pre>
  
  <p>However i get exception</p>
  
  <blockquote>
    <p>[15:57:43 ERR] Unhandled exception
    Amazon.Runtime.AmazonServiceException: Unable to find credentials</p>
    
    <p>Exception 1 of 5: System.InvalidOperationException: The
    app.config/web.config files for the application did not contain
    credential information    at
    Amazon.Runtime.AppConfigAWSCredentials..ctor() in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    977    at
    Amazon.Runtime.FallbackCredentialsFactory.&lt;>c.b__6_0() in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    2098    at
    Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean
    fallbackToAnonymous) in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs</p>
    
    <p>Exception 2 of 5: System.ArgumentException: App.config does not
    contain credentials information. Either add the AWSAccessKey and
    AWSSecretKey properties or the AWSProfileName property.    at
    Amazon.Runtime.StoredProfileAWSCredentials..ctor(String profileName,
    String profilesLocation) in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCreden
    at Amazon.Runtime.FallbackCredentialsFactory.&lt;>c.b__6_1() in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    2099    at
    Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean
    fallbackToAnonymous) in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs</p>
    
    <p>Exception 3 of 5: System.ArgumentException: Profile '' was not found
    or could not be loaded from the SDK credential store. Verify that the
    profile name and data are correct.    at
    Amazon.Runtime.StoredProfileFederatedCredentials..ctor(String
    profileName, String profilesLocation, WebProxy proxySettings) in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src    at
    Amazon.Runtime.FallbackCredentialsFactory.&lt;>c.b__6_2() in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    2101    at
    Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean
    fallbackToAnonymous) in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs</p>
    
    <p>Exception 4 of 5: System.InvalidOperationException: The environment
    variables AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN
    were not set with AWS credentials.    at
    Amazon.Runtime.EnvironmentVariablesAWSCredentials.FetchAWSCredentials()
    in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    856    at Amazon.Runtime.EnvironmentVariablesAWSCredentials..ctor() in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    836    at
    Amazon.Runtime.FallbackCredentialsFactory.&lt;>c.b__6_3() in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    2102    at
    Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean
    fallbackToAnonymous) in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs</p>
    
    <p>Exception 5 of 5: Amazon.Runtime.AmazonServiceException: Unable to
    reach credentials server    at
    Amazon.Runtime.URIBasedRefreshingCredentialHelper.GetContents(Uri uri)
    in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    1194    at
    Amazon.Runtime.InstanceProfileAWSCredentials.d__10.MoveNext()
    in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    at Amazon.Runtime.InstanceProfileAWSCredentials.GetFirstRole() in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    1422    at
    Amazon.Runtime.FallbackCredentialsFactory.ECSEC2CredentialsWrapper()
    in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    2129    at
    Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean
    fallbackToAnonymous) in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs</p>
    
    <p>at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean
    fallbackToAnonymous) in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs    at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials() in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AWSCredentials.cs:line
    2136    at Amazon.S3.AmazonS3Client..ctor(RegionEndpoint region) in
    E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Services\S3\Generated_bcl45\AmazonS3Client.cs:line
    80    at Utility.Program.Dowork() in
    C:\repos\poc\Utility\Utility\Program.cs:line 133    at
    Utility.Program.Main(String[] args) in
    C:\repos\poc\Utility\Utility\Program.cs:line 23</p>
  </blockquote>