public static async Task <bool> CreateTable(AmazonDynamoDBClient client) { var createTableRequest = new CreateTableRequest() { TableName = _tableName, ProvisionedThroughput = new ProvisionedThroughput() { ReadCapacityUnits = 1, WriteCapacityUnits = 1 } }; var attributeDefinitions = new List <AttributeDefinition>() { // Attribute definitions for table primary key { new AttributeDefinition() { AttributeName = "CustomerId", AttributeType = "S" } }, { new AttributeDefinition() { AttributeName = "OrderId", AttributeType = "N" } }, // Attribute definitions for index primary key { new AttributeDefinition() { AttributeName = "OrderCreationDate", AttributeType = "N" } }, { new AttributeDefinition() { AttributeName = "IsOpen", AttributeType = "N" } } }; createTableRequest.AttributeDefinitions = attributeDefinitions; // Key schema for table var tableKeySchema = new List <KeySchemaElement>() { { new KeySchemaElement() { AttributeName = "CustomerId", KeyType = "HASH" } }, //Partition key { new KeySchemaElement() { AttributeName = "OrderId", KeyType = "RANGE" } } //Sort key }; createTableRequest.KeySchema = tableKeySchema; var localSecondaryIndexes = new List <LocalSecondaryIndex>(); // OrderCreationDateIndex var orderCreationDateIndex = new LocalSecondaryIndex() { IndexName = "OrderCreationDateIndex" }; // Key schema for OrderCreationDateIndex var indexKeySchema = new List <KeySchemaElement>() { { new KeySchemaElement() { AttributeName = "CustomerId", KeyType = "HASH" } }, //Partition key { new KeySchemaElement() { AttributeName = "OrderCreationDate", KeyType = "RANGE" } } //Sort key }; orderCreationDateIndex.KeySchema = indexKeySchema; // Projection (with list of projected attributes) for // OrderCreationDateIndex var projection = new Projection() { ProjectionType = "INCLUDE" }; var nonKeyAttributes = new List <string>() { "ProductCategory", "ProductName" }; projection.NonKeyAttributes = nonKeyAttributes; orderCreationDateIndex.Projection = projection; localSecondaryIndexes.Add(orderCreationDateIndex); // IsOpenIndex var isOpenIndex = new LocalSecondaryIndex() { IndexName = "IsOpenIndex" }; // Key schema for IsOpenIndex indexKeySchema = new List <KeySchemaElement>() { { new KeySchemaElement() { AttributeName = "CustomerId", KeyType = "HASH" } }, //Partition key { new KeySchemaElement() { AttributeName = "IsOpen", KeyType = "RANGE" } } //Sort key }; // Projection (all attributes) for IsOpenIndex projection = new Projection() { ProjectionType = "ALL" }; isOpenIndex.KeySchema = indexKeySchema; isOpenIndex.Projection = projection; localSecondaryIndexes.Add(isOpenIndex); // Add index definitions to CreateTable request createTableRequest.LocalSecondaryIndexes = localSecondaryIndexes; Console.WriteLine("Creating table " + _tableName + "..."); await client.CreateTableAsync(createTableRequest); WaitUntilTableReady(client, _tableName); return(true); }