I am trying to interact with AWS DynamoDB from my website with AWS SDK PHP 3.0 using the code below:
$client = new \Aws\DynamoDb\DynamoDbClient(['version' => 'latest', 'region' => "ca-central-1"]);
$result_put = $client->putItem(array(
"TableName" => "Table_name",
"Item" => array(
"PK" => array("S" => "TEST"),
"SK" => array('S' => "123456")
)
));
$result_get = $client->getItem(array(
"TableName" => "Table_name",
"Key" => array(
"PK" => array("S" => "TEST"),
"SK" => array("S" => "123456")
)
));
I can put items in the table, however getItem always returns {}, even when I ask for 'ReturnConsumedCapacity' => 'INDEXES'.
My IAM permissions are:
{
"Effect": "Allow",
"Action": "dynamodb:*",
"Resource": "arn:aws:dynamodb:*:xxx:table/Table_name"
}
It works perfectly with AWS CLI. But I don't know what else to try to find the cause of the error in PHP.