|
32 | 32 | 'KeySchema' => [ |
33 | 33 | [ |
34 | 34 | 'AttributeName' => 'Id', |
35 | | - 'KeyType' => 'HASH' //Partition key |
| 35 | + 'KeyType' => 'HASH' //Partition key. |
36 | 36 | ] |
37 | 37 | ], |
38 | | - 'ProvisionedThroughput' => [ |
39 | | - 'ReadCapacityUnits' => 5, |
40 | | - 'WriteCapacityUnits' => 6 |
41 | | - ] |
| 38 | + 'BillingMode' => 'PAY_PER_REQUEST' // Use on-demand billing mode. |
42 | 39 | ]); |
43 | 40 |
|
44 | 41 | $dynamodb->waitUntil('TableExists', [ |
|
60 | 57 | #################################################################### |
61 | 58 | # Updating the table |
62 | 59 |
|
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. |
80 | 61 |
|
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"; |
93 | 63 |
|
94 | 64 | #################################################################### |
95 | 65 | # Deleting the table |
|
0 commit comments