We need to be able to set table name based on build environment. Consider the following class:
[DynamoDBTable("movies")]
public class Movie
{
[DynamoDBHashKey]
public string Title { get; set; }
[DynamoDBRangeKey(AttributeName = "Released")]
public DateTime ReleaseDate { get; set; }
public List<string> Genres { get; set; }
}
In serverless.yml, can the table name be set like this:
functions:
update-movies:
environment:
tableName: movies-prod
Then in the code we can load the table name dynamically based on the table name in the tableName variable. We prefer to use DynamoDBContext rather than DynamoDBv2.DocumentModel (which already has a solution here How do I dynamically change dynamodb tablename in c# using object persistence model)
Something like this in Java: https://medium.com/@onclouds/aws-lambda-use-different-dynamodb-tables-for-different-stages-5eda9f5378b2