Edit

Share via


Amazon DynamoDB grain persistence

In this article, you learn how to install and configure 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 method.

siloBuilder.AddDynamoDBGrainStorage(
    name: "profileStore",
    configureOptions: options =>
    {
        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 a non-default profile name, you can define those properties. First, view your credentials file using the following command:

cat ~/.aws/credentials

As an example, the following configuration shows how to 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 configuration 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 documentation.