public function addGlobalSecondaryIndex(DynamoDbIndex $gsi, $readCapacity = 5, $writeCapacity = 5) { if ($this->getGlobalSecondaryIndices(sprintf("/%s/", preg_quote($gsi->getName(), "/")))) { throw new \RuntimeException("Global Secondary Index exists, name = " . $gsi->getName()); } $args = ['AttributeDefinitions' => $gsi->getAttributeDefinitions(false), 'GlobalSecondaryIndexUpdates' => [['Create' => ['IndexName' => $gsi->getName(), 'KeySchema' => $gsi->getKeySchema(), 'Projection' => $gsi->getProjection(), 'ProvisionedThroughput' => ['ReadCapacityUnits' => $readCapacity, 'WriteCapacityUnits' => $writeCapacity]]]], 'TableName' => $this->tableName]; $this->dbClient->updateTable($args); }