tourdownunder
tourdownunder

Reputation: 1829

How to define the configuration for AWS DynamoDB in .Net 4 and C#

I'm using DynamoDB, where "User" is the Table and Model Object name. I get this error:

Requested resource not found: Table: User not found

web.config settings are as below.

<appSettings>
    <add key="AWSAccessKey" value="asdf" />
    <add key="AWSSecretKey" value="Vi+asdfsecretImnottelling" />
</appSettings>

I'm currently using my localhost to debug my application. Is this allowed?

Upvotes: 2

Views: 7210

Answers (2)

Meghnath Das
Meghnath Das

Reputation: 155

Create user by using IAM, it is a AWS service. Then do the following configuration in your app settings according to the user you have added:

"AWS": {
"Profile": "",
"AccessKey": "",
"SecretKey": "",
"Region": ""}

The following method is easy to create DynamoDb client with basic credential:

AmazonDynamoDBClient awsDbClient = new AmazonDynamoDBClient(strAccessKey, strSecretKey, Amazon.RegionEndpoint.GetBySystemName(strRegion));

For aws DB access library you can visit this link: https://github.com/MeghnathDas/DynamoDbPlugin

Upvotes: 0

tourdownunder
tourdownunder

Reputation: 1829

I didn't set the ServiceURL which is a problem as I'm not using the default region.

By default, AWS SDK for .NET sets the endpoint to

https://dynamodb.us-east-1.amazonaws.com

You can also set the endpoint explicitly as shown in this C# code snippet:

private static void CreateClient()
{
    AmazonDynamoDBConfig config = new AmazonDynamoDBConfig();
    config.ServiceURL = "http://dynamodb.us-east-1.amazonaws.com";
    client = new AmazonDynamoDBClient(config);
}

Amazon's "What Is Amazon DynamoDB?" will help too.

Upvotes: 1

Related Questions