I have ASP.NET Core 2 application. I have configured AWS in appsettings.json
like below
"AWS": {
"Profile": "default",
"ProfilesLocation": "D:\\_profiles\\awsprofile"
}
i made sure i have the awsprofile file available at that location with below information
[default]
aws_access_key_id = XXXXXX
aws_secret_access_key = XXXXXXXXXXX
Then im trying to create instance of S3Client like below
var regionEndPoint = RegionEndpoint.GetBySystemName("us-west-1");
var client = new AmazonS3Client(regionEndPoint));
However, i am getting exception Unable to find the 'default' profile in CredentialProfileStoreChain.
Application startup exception: Amazon.Runtime.AmazonServiceException: Unable to find credentials
Exception 1 of 3: Amazon.Runtime.AmazonClientException: Unable to find the 'default' profile in CredentialProfileStoreChain. at Amazon.Runtime.FallbackCredentialsFactory.GetAWSCredentials(ICredentialProfileSource source) at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)
Exception 2 of 3: 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.FetchCredentials()
at Amazon.Runtime.EnvironmentVariablesAWSCredentials..ctor() at Amazon.Runtime.FallbackCredentialsFactory.<>c.b__9_1() at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)Exception 3 of 3: System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found). at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() at System.Net.Http.HttpClient.d__27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.Util.AsyncHelpers.<>c__DisplayClass1_1
1.<<RunSync>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Amazon.Runtime.Internal.Util.AsyncHelpers.ExclusiveSynchronizationContext.BeginMessageLoop() at Amazon.Runtime.Internal.Util.AsyncHelpers.RunSync[T](Func1 task)
at Amazon.Util.AWSSDKUtils.DownloadStringContent(Uri uri, TimeSpan timeout) at Amazon.Runtime.URIBasedRefreshingCredentialHelper.GetContents(Uri uri) at Amazon.Runtime.InstanceProfileAWSCredentials.d__10.MoveNext() at Amazon.Runtime.InstanceProfileAWSCredentials.GetFirstRole() at Amazon.Runtime.FallbackCredentialsFactory.ECSEC2CredentialsWrapper()
at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous) at XXXXXXXXXXXXXXXXXXXX.cs:line 30 at Api.Startup.ConfigureServices(IServiceCollection services) in D:\Jenkins\XXXXXXXXXXXXXXXXXXXX\Src\Api\Startup.cs:line 75 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6] Application startup exception Amazon.Runtime.AmazonServiceException: Unable to find credentials
Exception 1 of 3: Amazon.Runtime.AmazonClientException: Unable to find the 'default' profile in CredentialProfileStoreChain. at Amazon.Runtime.FallbackCredentialsFactory.GetAWSCredentials(ICredentialProfileSource source) at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)
Exception 2 of 3: 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.FetchCredentials()
at Amazon.Runtime.EnvironmentVariablesAWSCredentials..ctor() at Amazon.Runtime.FallbackCredentialsFactory.<>c.b__9_1() at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)Exception 3 of 3: System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found). at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() at System.Net.Http.HttpClient.d__27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.Util.AsyncHelpers.<>c__DisplayClass1_1
1.<<RunSync>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Amazon.Runtime.Internal.Util.AsyncHelpers.ExclusiveSynchronizationContext.BeginMessageLoop() at Amazon.Runtime.Internal.Util.AsyncHelpers.RunSync[T](Func1 task)
at Amazon.Util.AWSSDKUtils.DownloadStringContent(Uri uri, TimeSpan timeout) at Amazon.Runtime.URIBasedRefreshingCredentialHelper.GetContents(Uri uri) at Amazon.Runtime.InstanceProfileAWSCredentials.d__10.MoveNext() at Amazon.Runtime.InstanceProfileAWSCredentials.GetFirstRole() at Amazon.Runtime.FallbackCredentialsFactory.ECSEC2CredentialsWrapper()
at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous) at XXXXXXXXXXXXXXXXXXXX:line 30 at Api.Startup.ConfigureServices(IServiceCollection services) in D:\Jenkins\XXXXXXXXXXXXXXXXXXXX\Startup.cs:line 75 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
Unhandled Exception: Amazon.Runtime.AmazonServiceException: Unable to find credentials
Exception 1 of 3: Amazon.Runtime.AmazonClientException: Unable to find the 'default' profile in CredentialProfileStoreChain. at Amazon.Runtime.FallbackCredentialsFactory.GetAWSCredentials(ICredentialProfileSource source) at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)
Exception 2 of 3: 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.FetchCredentials()
at Amazon.Runtime.EnvironmentVariablesAWSCredentials..ctor() at Amazon.Runtime.FallbackCredentialsFactory.<>c.b__9_1() at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)Exception 3 of 3: System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found). at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() at System.Net.Http.HttpClient.d__27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.Util.AsyncHelpers.<>c__DisplayClass1_1
1.<<RunSync>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Amazon.Runtime.Internal.Util.AsyncHelpers.ExclusiveSynchronizationContext.BeginMessageLoop() at Amazon.Runtime.Internal.Util.AsyncHelpers.RunSync[T](Func1 task)
at Amazon.Util.AWSSDKUtils.DownloadStringContent(Uri uri, TimeSpan timeout) at Amazon.Runtime.URIBasedRefreshingCredentialHelper.GetContents(Uri uri) at Amazon.Runtime.InstanceProfileAWSCredentials.d__10.MoveNext() at Amazon.Runtime.InstanceProfileAWSCredentials.GetFirstRole() at Amazon.Runtime.FallbackCredentialsFactory.ECSEC2CredentialsWrapper()
at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous) at XXXXXXXXXXXXXXXXXXXX:line 30 at XXXXXXXXXXXXXXXXXXXX\Src\Api\Startup.cs:line 75 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at Api.Program.Main(String[] args) in D:\Jenkins\XXXXXXXXXXXXXXXXXXXX\Src\Api\Program.cs:line 20