Skip to content

Commit 2042841

Browse files
authored
PHP updated the PHP Create table example (#7300)
1 parent bc14b74 commit 2042841

File tree

2 files changed

+5
-38
lines changed

2 files changed

+5
-38
lines changed

php/example_code/dynamodb/GettingStarted/MoviesCreateTable.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@
4040
],
4141

4242
],
43-
'ProvisionedThroughput' => [
44-
'ReadCapacityUnits' => 10,
45-
'WriteCapacityUnits' => 10
46-
]
43+
'BillingMode' => 'PAY_PER_REQUEST' // Use on-demand billing mode.
4744
];
4845

4946
try {

php/example_code/dynamodb/Tables_CRUD.php

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@
3232
'KeySchema' => [
3333
[
3434
'AttributeName' => 'Id',
35-
'KeyType' => 'HASH' //Partition key
35+
'KeyType' => 'HASH' //Partition key.
3636
]
3737
],
38-
'ProvisionedThroughput' => [
39-
'ReadCapacityUnits' => 5,
40-
'WriteCapacityUnits' => 6
41-
]
38+
'BillingMode' => 'PAY_PER_REQUEST' // Use on-demand billing mode.
4239
]);
4340

4441
$dynamodb->waitUntil('TableExists', [
@@ -60,36 +57,9 @@
6057
####################################################################
6158
# Updating the table
6259

63-
echo "# Updating the provisioned throughput of table $tableName.\n";
64-
try {
65-
$response = $dynamodb->updateTable([
66-
'TableName' => $tableName,
67-
'ProvisionedThroughput' => [
68-
'ReadCapacityUnits' => 6,
69-
'WriteCapacityUnits' => 7
70-
]
71-
]);
72-
73-
$dynamodb->waitUntil('TableExists', [
74-
'TableName' => $tableName,
75-
'@waiter' => [
76-
'delay' => 5,
77-
'maxAttempts' => 20
78-
]
79-
]);
60+
// No need to update provisioned throughput as we are using PAY_PER_REQUEST mode.
8061

81-
echo "New provisioned throughput settings:\n";
82-
83-
$response = $dynamodb->describeTable(['TableName' => $tableName]);
84-
85-
echo "Read capacity units: " .
86-
$response['Table']['ProvisionedThroughput']['ReadCapacityUnits'] . "\n";
87-
echo "Write capacity units: " .
88-
$response['Table']['ProvisionedThroughput']['WriteCapacityUnits'] . "\n";
89-
} catch (DynamoDbException $e) {
90-
echo $e->getMessage() . "\n";
91-
exit("Unable to update table $tableName\n");
92-
}
62+
echo "# Skipping table update for throughput settings (not needed for PAY_PER_REQUEST).\n";
9363

9464
####################################################################
9565
# Deleting the table

0 commit comments

Comments
 (0)