Skip to content
Advertisement

Amazon DynamoDB InvalidSignatureException

From this code I’m getting the error below

require "vendor/autoload.php";
use AwsCommonAws;
use AwsDynamoDbDynamoDbClient;
use AwsDynamoDbEnumComparisonOperator;
use AwsDynamoDbEnumKeyType;
use AwsDynamoDbEnumType;

$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(
        array(
           "AttributeName" => "Id",
           "AttributeType" => Type::NUMBER
        )
     ),
     "KeySchema" => array(
        array(
           "AttributeName" => "Id",
           "KeyType" => KeyType::HASH
        )
    ),
    "ProvisionedThroughput" => array(
        "ReadCapacityUnits"    => 5,
        "WriteCapacityUnits" => 6
    )
));

print_r($result->getPath('TableDescription'));

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:
InvalidSignatureException, 
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.9n  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.

Advertisement

Answer

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
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement