Amazon DynamoDB InvalidSignatureException

Gle*_*ton 32 php amazon-web-services amazon-dynamodb

从这段代码我得到下面的错误

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(
        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'));
Run Code Online (Sandbox Code Playgroud)

尝试将表添加到AWS的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.9\n  thrown in
/var/www/vendor/aws/aws-sdk-php/src/Aws/Common/Exception/NamespaceExceptionFactory.php on
line 91
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已经:

  • 检查验证密钥和密钥是否正确,它们是.
  • 更新了cURL
  • 当我输入虚假身份验证权限时,错误没有改变.

and*_*scu 88

您的本地系统时间似乎不正确.我在AWS S3上遇到了类似的问题,我的系统时钟偏差了30分钟.

如果您正在运行ubuntu,请尝试更新系统时间:

sudo ntpdate ntp.ubuntu.com
Run Code Online (Sandbox Code Playgroud)

  • 在mac`sudo ntpdate -u time.apple.com`上 (8认同)
  • 只是第87次我谷歌回答 (3认同)