Home » Php » php – Amazon DynamoDB InvalidSignatureException

php – Amazon DynamoDB InvalidSignatureException

Posted by: admin April 23, 2020 Leave a comment


From this code I’m getting the error below

require "vendor/autoload.php";
use Aws\Common\Aws;
use Aws\DynamoDb\DynamoDbClient;
use Aws\DynamoDb\Enum\ComparisonOperator;
use Aws\DynamoDb\Enum\KeyType;
use Aws\DynamoDb\Enum\Type;

$aws = Aws::factory(array(
'key'    => '[clipped]',
'secret' => '[clipped]',
'region' => Region::US_WEST_1

$client = $aws->get("dynamodb");
$tableName = "ExampleTable";

$result = $client->createTable(array(
    "TableName" => $tableName,
    "AttributeDefinitions" => array(
           "AttributeName" => "Id",
           "AttributeType" => Type::NUMBER
     "KeySchema" => array(
           "AttributeName" => "Id",
           "KeyType" => KeyType::HASH
    "ProvisionedThroughput" => array(
        "ReadCapacityUnits"    => 5,
        "WriteCapacityUnits" => 6


I’m getting the following error when trying to add a table into AWS’s DynamoDB.

PHP Fatal error:  Uncaught Aws\DynamoDb\Exception\DynamoDbException: AWS Error Code:
Status Code: 400, 
AWS Request ID: [clipped], 
AWS Error Type: client, 
AWS Error Message: Signature expired: 20130818T021159Z is now earlier than  
20130818T021432Z (20130818T022932Z - 15 min.), 
User-Agent: aws-sdk-php2/2.4.3 Guzzle/3.7.2 curl/7.21.6 PHP/5.3.6-13ubuntu3.9\n  thrown in
/var/www/vendor/aws/aws-sdk-php/src/Aws/Common/Exception/NamespaceExceptionFactory.php on
line 91

So far I’ve:

  • Checked to see if Authentication Key and Secret Key were correct, they were.
  • Updated cURL
  • When I put false authentication permissions in, the error didn’t change.
How to&Answers:

It seems that your local system time might be incorrect. I’ve had a similar problem with AWS S3, where my system clock was skewed by 30 mins.

If you’re running ubuntu, try updating your system time:

sudo ntpdate ntp.ubuntu.com


You can also restart your date service to solve the problem if you’ve already got ntpdate installed.

sudo service ntpdate stop
sudo service ntpdate start


If you are using docker-machine on Mac, you can resolve with this command:

docker-machine ssh default 'sudo ntpclient -s -h pool.ntp.org'


Quick note for vagrant projects: this is usually resolved by vagrant reload.