Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Use pay per request for dynamodb by default #600

Merged
merged 2 commits into from
Jul 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.BillingMode;
import software.amazon.awssdk.services.dynamodb.model.CreateTableRequest;
import software.amazon.awssdk.services.dynamodb.model.Delete;
import software.amazon.awssdk.services.dynamodb.model.DescribeLimitsResponse;
import software.amazon.awssdk.services.dynamodb.model.GetItemRequest;
import software.amazon.awssdk.services.dynamodb.model.GetItemResponse;
import software.amazon.awssdk.services.dynamodb.model.KeySchemaElement;
Expand Down Expand Up @@ -161,8 +161,7 @@ private TableDescription createTable(
}
catch(final ResourceNotFoundException e)
{
final DescribeLimitsResponse limits = this.client.describeLimits();
final CreateTableRequest request = CreateTableRequest.builder()
final CreateTableRequest request = CreateTableRequest.builder()
.tableName(name)
.keySchema(
KeySchemaElement.builder()
Expand All @@ -184,10 +183,7 @@ private TableDescription createTable(
.attributeType(ScalarAttributeType.N)
.build()
)
.provisionedThroughput(builder -> builder
.readCapacityUnits (limits.tableMaxReadCapacityUnits ())
.writeCapacityUnits(limits.tableMaxWriteCapacityUnits())
)
.billingMode(BillingMode.PAY_PER_REQUEST)
.build()
;
return this.client.createTable(request).tableDescription();
Expand Down