Creating a DynamoDB table with a Global Secondary Index using the AWS SDK for PHP

Now let's see how to create a DynamoDB table with a Global Secondary Index using the AWS SDK for PHP.

Getting ready

To perform this recipe, you can use the IDE of your choice.

How to do it…

In the earlier chapters, we have seen how to create a DynamoDB table. Now, we are going to see how to create a DynamoDB table using a Global Secondary Index:

  1. Instantiate the DynamoDB client for PHP. Specify the AWS region in which you wish to create the table:
    $client = DynamoDbClient::factory(array(
        'profile' => 'default',
        'region' => 'us-west-1'  
    ));
  2. Now we have to initialize the create table request, specifying the AttributesDefinition, KeySchema, and GlobalSecondaryIndex specifications. ...

Get DynamoDB Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.