Using .net core here:
I am having the following issue while connecting to my AWS dynamo db.
Below is my startup class
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<UserData>>(provider => new DynamoDbManager<UserData>(client, dynamoDbOptions.UserData));
}
Below is my appsettings:
"AWS": {
"Region": "us-east-1",
"AwsId": "xxxx",
"AwsPassword": "xxxxx"
},
"DynamoDbTables": {
"UserData": "UserDataTest"
}
FYI below is my DynamoDbManager class:
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
};
}
}
When I run my app it gives me error as:
An error occurred while starting the application.
AmazonServiceException: Unable to find credentials
System.InvalidOperationException: The environment variables AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN were not set with AWS credentials.
But I never set my environment credentials before and it was working fine. Not sure what changed now and started giving me this error.