Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Last active August 18, 2019 14:24
Show Gist options
  • Save gistlyn/d607e070cca190e0d59368dd6b9b147c to your computer and use it in GitHub Desktop.
Save gistlyn/d607e070cca190e0d59368dd6b9b147c to your computer and use it in GitHub Desktop.
Use AWS DynamoDB and PocoDynamo
dotnet add package ServiceStack.Aws
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ServiceStack;
using ServiceStack.Aws;
using ServiceStack.Aws.DynamoDb;
using Amazon;
using Amazon.DynamoDBv2;
namespace MyApp
{
public class ConfigureDynamoDb : IConfigureServices
{
IConfiguration Configuration { get; }
public ConfigureDynamoDb(IConfiguration configuration) => Configuration = configuration;
public void Configure(IServiceCollection services)
{
var awsDb = new AmazonDynamoDBClient("keyId","key", new AmazonDynamoDBConfig {
ServiceURL = Configuration.GetConnectionString("DynamoDb") ?? "http://localhost:8000"
});
var db = new PocoDynamo(awsDb);
services.AddSingleton<IAmazonDynamoDB>(awsDb);
services.AddSingleton<IPocoDynamo>(db);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment