I have locally running DynamoDB and create a table using the shell( localhost:8000/shell/).
Can confirm with the following code:
var params = {
ExclusiveStartTableName: 'STRING_VALUE',
Limit: 10
};
dynamodb.listTables(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
outputs
{"TableNames":["myTable"]}
However when I call getItem/PutItem from PHP code it throws the following error
[Mon Dec 14 11:22:48.266930 2015] [:error] [pid 12] [client 10.0.2.2:58042] PHP Fatal error: Uncaught Aws\DynamoDb\Exception\ResourceNotFoundException: AWS Error Code: ResourceNotFoundException, Status Code: 400, AWS Request ID: 8de599f1-7aa6-4147-b2f8-b3acc74b09da, AWS Error Type: client, AWS Error Message: Cannot do operations on a non-existent table, User-Agent: aws-sdk-php2/2.8.24 Guzzle/3.9.3 curl/7.35.0 PHP/5.5.9-1ubuntu4.14\n thrown in /opt/lib/aws/sdk/vendor/aws/aws-sdk-php/src/Aws/Common/Exception/NamespaceExceptionFactory.php on line 91
And this is how I create the client
$this->client = DynamoDbClient::factory(array(
'key' => 'YOUR_KEY',
'secret' => 'YOUR_SECRET',
'profile' => 'default',
'region' => 'us-west-2',
//'version' => '2012-08-10',
'endpoint'=> 'http://localhost:8000',
//'debug' => true
));
If the endpoint were wrong, client creation itself would have thrown error but in this case tables are not getting created as per PHP
echo "List of tables";
$iterator = $this->client->()->getIterator('ListTables');
foreach ($iterator as $tableName) {
echo $tableName . "\n";
}
prints nothing.