我正在嘗試使用 DynamoDB 客戶端通過 aws-sdk(2.11.31) 創建一個新表,如下所示;
new_table_definition = {
attribute_definitions: [
{
attribute_name: 'user',
attribute_type: 'S'
},
{
attribute_name: 'timestamp',
attribute_type: 'N'
},
{
attribute_name: 'uuid',
attribute_type: 'S'
}
],
key_schema: [
{
attribute_name: 'uuid',
key_type: 'HASH'
},
{
attribute_name: 'timestamp',
key_type: 'RANGE'
}
],
global_secondary_indexes: [
{
index_name: 'user-timestamp-index',
key_schema: [
{
attribute_name: 'user',
key_type: 'HASH'
},
{
attribute_name: 'timestamp',
key_type: 'RANGE'
}
],
projection: {
projection_type: 'KEYS_ONLY'
},
provisioned_throughput: {
read_capacity_units: 0,
write_capacity_units: 0,
}
}
],
billing_mode: "PAY_PER_REQUEST",
provisioned_throughput: {
read_capacity_units: 0,
write_capacity_units: 0
},
table_name: "A_NEW_TABLE"
}
Dynamo::Table.create(new_table_definition)
但是我收到以下錯誤:
ArgumentError: no such member :billing_mode
據我了解,這是 sdk v2 檔案中描述的計費模式的正確密鑰和格式。洗掉計費模式可以很好地創建表格,但我隨后被迫進入 AWS 控制臺手動將其更改為按需。
紅寶石 - 2.3.0
導軌 - 3.2.22.5
aws-sdk - 2.11.31
相關回溯:
2.3.3 :464 > Dynamo::Table.create(new_table_definition)
ArgumentError: no such member :billing_mode
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/seahorse/model/shapes.rb:212:in `member'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb:165:in `block in structure'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb:164:in `each'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb:164:in `with_object'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb:164:in `structure'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb:152:in `apply'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb:121:in `translate_input'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb:111:in `call'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:20:in `call'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/aws-sdk-core/plugins/idempotency_token.rb:18:in `call'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/aws-sdk-core/plugins/param_converter.rb:20:in `call'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/seahorse/client/plugins/response_target.rb:21:in `call'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/seahorse/client/request.rb:70:in `send_request'
from shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.11.31/lib/seahorse/client/base.rb:207:in `block (2 levels) in define_operation_methods'
uj5u.com熱心網友回復:
我遇到的具體問題是 gem 版本。它似乎不支持 billing_mode。
我在測驗新版本時還發現的另一個問題實際上是同時發送 billing_mode 和 provisioned_throughput 值。這是一個非此即彼的情況。
If read/write capacity mode is PAY_PER_REQUEST the value is set to 0.本檔案中的這一行引起了混淆https://docs.aws.amazon.com/sdk-for-ruby/v2/api/Aws/DynamoDB/Types/ProvisionedThroughput.html
看到這里它告訴你不要通過它: https ://docs.aws.amazon.com/sdk-for-ruby/v2/api/Aws/DynamoDB/Client.html#create_table-instance_method
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/477397.html
