private static IAmazonDynamoDB CreateClient( ICredentialsProvider credentialsProvider, IDynamoDbOptions <T> options ) { AWSCredentials credentials = credentialsProvider.GetCredentials(options.CredentialsProfile); if (!string.IsNullOrWhiteSpace(options.Role)) { credentials = credentialsProvider.AssumeRole( credentials, options.Role ); } if (!string.IsNullOrWhiteSpace(options.RegionEndpoint)) { AmazonDynamoDBConfig config = new AmazonDynamoDBConfig { RegionEndpoint = RegionEndpoint.GetBySystemName(options.RegionEndpoint) }; return(new AmazonDynamoDBClient(credentials, config)); } return(new AmazonDynamoDBClient(credentials)); }
public DynamoDbContext( ICredentialsProvider credentialsProvider, IDynamoDbOptions <T> options ) { if (options is null) { throw new ArgumentException($"{nameof( options )} must not be null.", nameof(options)); } if (credentialsProvider is null) { throw new ArgumentException($"{nameof( credentialsProvider )} must not be null.", nameof(credentialsProvider)); } Client = CreateClient(credentialsProvider, options); Context = new DynamoDBContext(Client); }