我有一个PHP应用程序,使用symfony2,silex和AWS DynamoDB SDK。它一直很好。 DynamoDB是在东海岸创建的。
我们有第二个AWS账户,我们复制了DynamoDB结构(表名,表结构等都是一样的)。此DynamoDB安装位于西海岸(加利福尼亚州北部)。
当我们尝试使用第二个AWS凭据时,我的应用程序无效。
当我尝试做的时候:
$res = $app['db']->describe_table(array('TableName' => 'account'));
我转储$ res,这是我得到的:
CFResponse Object
(
[header] => Array
(
[x-amzn-requestid] => xxxxxxxxxxxxxxxxxxxxxxxxxx
[x-amz-crc32] => xxxxxxxxxxxxx
[content-type] => application/x-amz-json-1.0
[content-length] => 143
[date] => Wed, 28 Nov 2012 20:49:31 GMT
[_info] => Array
(
[url] => https://dynamodb.us-east-1.amazonaws.com/
[content_type] => application/x-amz-json-1.0
[http_code] => 400
[header_size] => 224
[request_size] => 896
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.363967
[namelookup_time] => 0.008497
[connect_time] => 0.091183
[pretransfer_time] => 0.263514
[size_upload] => 28
[size_download] => 143
[speed_download] => 392
[speed_upload] => 76
[download_content_length] => 143
[upload_content_length] => 0
[starttransfer_time] => 0.363929
[redirect_time] => 0
[certinfo] => Array
(
)
[redirect_url] =>
[method] => POST
)
[x-aws-stringtosign] => AWS4-HMAC-SHA256
20121128T204931Z
20121128/us-east-1/dynamodb/aws4_request
xxxxxxxxxxxxxxxxxxxxxxx
[x-aws-canonicalrequest] => POST
/
content-length:28
content-type:application/x-amz-json-1.0
host:dynamodb.us-east-1.amazonaws.com
x-amz-date:20121128T204931Z
x-amz-target:DynamoDB_20111205.DescribeTable
content-length;content-type;host;x-amz-date;x-amz-target
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[x-aws-request-headers] => Array
(
[Content-Length] => 28
[Content-Type] => application/x-amz-json-1.0
[Host] => dynamodb.us-east-1.amazonaws.com
[X-Amz-Date] => 20121128T204931Z
[X-Amz-Target] => DynamoDB_20111205.DescribeTable
[Authorization] => AWS4-HMAC-SHA256 Credential=AKIAJAIBF2DKGD2UD3YQ/20121128/us-east-1/dynamodb/aws4_request,SignedHeaders=content-length;content-type;host;x-amz-date;x-amz-target,Signature=xxxxxxxxxxxxxxxxxxxxxxxx
[Expect] =>
)
[x-aws-body] => {"TableName":"account"}
)
[body] => CFSimpleXML Object
(
[__type] => com.amazonaws.dynamodb.v20111205#ResourceNotFoundException
[message] => Requested resource not found: Table: account not found
)
[status] => 400
)
我认为唯一需要的配置是AWS DynamoDB SDK,在config.inc.php文件中,我只能配置凭据。情况似乎并非如此,因为响应中包含所有这些对东海岸的引用以及我所针对的DynamoDB表位于西海岸。有什么想法我怎么能告诉它亚马逊SDK指向另一个地区?我应该关注的任何其他问题?
答案 0 :(得分:1)
解决了它。它被埋没在文档中(亚马逊认为这个产品及其文档BETA)。
在使用$ app ['db']之前,我需要这样做:
$app['db']->set_region('dynamodb.us-west-1.amazonaws.com');
或我的DynamoDB创建的任何区域。亚马逊提供了一些区域常量作为amazonDynamodb类的一部分,但我在使用它们时遇到了麻烦。因此,您可以使用像REGION_US_W1
这样的东西,而不是'dynamodb.us-west-1.amazonaws.com'。似乎默认使用了REGION_US_E1,所以如果你在那个地区,你可能不需要设置任何东西,但这样做可能是明智的,因为亚马逊可能会修改SDK类