Amazon DynamoDB grain persistence

In this article, you'll learn how to install and configure the Amazon DynamoDB grain persistence.

Installation

Install the Microsoft.Orleans.Persistence.DynamoDB package from NuGet.

Configuration

Configure the DynamoDB grain persistence provider using the DynamoDBSiloBuilderExtensions.AddDynamoDBGrainStorage extension methods.

siloBuilder.AddDynamoDBGrainStorage(
    name: "profileStore",
    configureOptions: options =>
    {
        options.UseJson = true;
        options.AccessKey = "<DynamoDB access key>";
        options.SecretKey = "<DynamoDB secret key>";
        options.Service = "<DynamoDB region name>"; // Such as "us-west-2"
    });

If your authentication method requires a token or non-default profile name, you can define those properties using the following command:

cat ~/.aws/credentials

As an example, the following command will configure the DynamoDB grain persistence provider to use the default profile from the ~/.aws/credentials file:

[YOUR_PROFILE_NAME]
aws_access_key_id = ***
aws_secret_access_key = ***
aws_security_token = ***
aws_session_expiration = ***
aws_session_token = ***

This allows for both types of authentication credentials:

  • access key & secret key
  • access key & secret key & token
siloBuilder.AddDynamoDBGrainStorage(
  name: "profileStore",
  configureOptions: options =>
  {
      options.UseJson = true;
      options.AccessKey = "***";
      options.SecretKey = "***";
      options.Service = "***";
      options.ProfileName = "***";
      options.Token = "***";
  });

For more information on AWS credentials and named profiles, see AWS Credentials and Named profiles in the AWS SDK for .NET Developer Guide.