1

symfony2、silex、および AWS DynamoDB SDK を使用する PHP アプリケーションがあります。それはうまくいっています。DynamoDB は東海岸で作成されます。

2 つ目の AWS アカウントがあり、DynamoDB 構造を複製しました (テーブル名、テーブル構造などはすべて同じです)。この DynamoDB インストールは西海岸 (北カリフォルニア) にあります。

2 番目の 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 テーブルは西海岸にあるため、これは当てはまらないようです。AmazonSDKに別のリージョンを指すように指示する方法はありますか? 私が心配する必要がある他の問題はありますか?

4

1 に答える 1

1

Solved it. It was buried in the docs (Amazon considers this product and its docs BETA).

Prior to using $app['db'], I need to do:

$app['db']->set_region('dynamodb.us-west-1.amazonaws.com');

or whatever region my DynamoDB was created in. Amazon provides some region constants as part of the amazonDynamodb class, but I'm having trouble using them. So, instead of 'dynamodb.us-west-1.amazonaws.com', you can use something like REGION_US_W1

It seems as if by default, the REGION_US_E1 is used, so if you're in that region, you probably don't need to set anything, but it might be wise to do so, as Amazon may modify the SDK classes.

于 2012-11-30T01:27:40.603 に答える