Book Image

DynamoDB Cookbook

By : Tanmay Deshpande
Book Image

DynamoDB Cookbook

By: Tanmay Deshpande

Overview of this book

Table of Contents (18 chapters)
DynamoDB Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Updating a table using the AWS SDK for PHP


Now, let's understand how to update a DynamoDB table using the AWS SDK for PHP.

Getting ready

You can use the IDE of your choice to code these recipes.

How to do it…

In this recipe, we will learn how to update the read and write capacity units for an already created table:

  1. Create an instance of the DynamoDB client and invoke the updateTable method, providing the details of the new provisioned throughout capacity units. Here, we will update the read and write capacity units to two:

    $tableName = 'productTablePHP';
    $result = $client->updateTable(array(
        'TableName' => $tableName,
        'ProvisionedThroughput'    => array(
            'ReadCapacityUnits'    => 2,        
            'WriteCapacityUnits' => 2          
        )
    ));
  2. DynamoDB takes some time to make the changes effective. So, it's a best practice to wait until the table gets effective again:

    $client->waitUntilTableExists(array('TableName' => $tableName));

How it works…

Once we invoke...