Managing dev/staging/production on DynamoDB?

后端 未结 5 2273
被撕碎了的回忆
被撕碎了的回忆 2020-12-14 17:10

We\'re starting to use DynamoDB, and want separate environments for dev/staging/production. We can\'t figure out a natural way to do this---do we just create separate AWS ac

5条回答
  •  醉话见心
    2020-12-14 17:24

    I can't understand why there is'nt a AWS solution for handling DB-versions like production and test in DynamoDB!? Having multiple AWS accounts is a hassle.

    It also becomes a big problem to prefix the table names if you get the items by using the c# class attribute [DynamoDBTable("Users")] and fetching the data with DynamoDBContext.Load(userId);

    As attributes values can't change during runtime I ended up with this soluting using conditonal compilation symbols and setting constants that can be used as the class attribute value.

    public static class DynamoDbTablesConfiguration
    {
            #if Debug
                public const string UserTable = "Users_Dev";
            #endif
    
            #if Release
                public const string UserTable = "Users_Production";
            #endif
    }
    
    [DynamoDBTable(DynamoDbTablesConfiguration.UserTable)]
    public class User
    {
    }
    

    Make sure you set the "conditonal compilation symbols" value by right click on project > Properties > Build > "conditonal compilation symbols".

    Not a perfect solution but I don't see any other options here if I don't want to create another AWS account.

提交回复
热议问题