I have the following code:
public void ConfigureServices(IServiceCollection services)
{
// AWS Options
var awsOptions = Configuration.GetAWSOptions();
services.AddDefaultAWSOptions(awsOptions);
var client = awsOptions.CreateServiceClient<IAmazonDynamoDB>();
var dynamoDbOptions = new DynamoDbOptions();
ConfigurationBinder.Bind(Configuration.GetSection("DynamoDbTables"), dynamoDbOptions);
services.AddScoped<IDynamoDbManager<MyModel>>(provider => new DynamoDbManager<MyModel>(client, dynamoDbOptions.MyModel));
}
public class DynamoDbManager<T> : DynamoDBContext, IDynamoDbManager<T> where T : class
{
private DynamoDBOperationConfig _config;
public DynamoDbManager(IAmazonDynamoDB client, string tableName) : base(client)
{
_config = new DynamoDBOperationConfig()
{
OverrideTableName = tableName
};
}
}
My Appsettings.json is as:
{
"AWS": {
"Region": "us-east-1",
"AwsId": "xxx",
"AwsPassword": "xxx"
},
"DynamoDbTables": {
"MyModel": "MyTable"
}
}
When I run my code I am getting the error:
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) in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Credentials\FallbackCredentialsFactory.cs:line 72
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.
Exception 3 of 3: System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: The operation timed out at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
I have tried many things but not getting this to work.
I have tried:
Setting up profile as: Amazon.Runtime.AmazonServiceException: Unable to find credentials
And also tried settingup of environment variables:
https://github.com/aws/aws-sdk-net/issues/499
But still cannot get past this error.