xxxxxxxxxx
public static String createTableComKey(DynamoDbClient ddb, String tableName) {
CreateTableRequest request = CreateTableRequest.builder()
.attributeDefinitions(
AttributeDefinition.builder()
.attributeName("Language")
.attributeType(ScalarAttributeType.S)
.build(),
AttributeDefinition.builder()
.attributeName("Greeting")
.attributeType(ScalarAttributeType.S)
.build())
.keySchema(
KeySchemaElement.builder()
.attributeName("Language")
.keyType(KeyType.HASH)
.build(),
KeySchemaElement.builder()
.attributeName("Greeting")
.keyType(KeyType.RANGE)
.build())
.provisionedThroughput(
ProvisionedThroughput.builder()
.readCapacityUnits(new Long(10))
.writeCapacityUnits(new Long(10)).build())
.tableName(tableName)
.build();
String tableId = "";
try {
CreateTableResponse result = ddb.createTable(request);
tableId = result.tableDescription().tableId();
return tableId;
} catch (DynamoDbException e) {
System.err.println(e.getMessage());
System.exit(1);
}
return "";
}
https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/examples-dynamodb-tables.html