Cookie の設定を選択する

当社は、当社のサイトおよびサービスを提供するために必要な必須 Cookie および類似のツールを使用しています。当社は、パフォーマンス Cookie を使用して匿名の統計情報を収集することで、お客様が当社のサイトをどのように利用しているかを把握し、改善に役立てています。必須 Cookie は無効化できませんが、[カスタマイズ] または [拒否] をクリックしてパフォーマンス Cookie を拒否することはできます。

お客様が同意した場合、AWS および承認された第三者は、Cookie を使用して便利なサイト機能を提供したり、お客様の選択を記憶したり、関連する広告を含む関連コンテンツを表示したりします。すべての必須ではない Cookie を受け入れるか拒否するには、[受け入れる] または [拒否] をクリックしてください。より詳細な選択を行うには、[カスタマイズ] をクリックしてください。

AWS SDK を使用してウォームスループットで DynamoDB テーブル設定を更新する

フォーカスモード
AWS SDK を使用してウォームスループットで DynamoDB テーブル設定を更新する - Amazon DynamoDB

次のコード例は、テーブルのウォームスループット設定を更新する方法を示しています。

Java
SDK for Java 2.x

既存の DynamoDB テーブルのウォームスループット設定を更新します。

import software.amazon.awssdk.services.dynamodb.DynamoDbClient; import software.amazon.awssdk.services.dynamodb.model.DynamoDbException; import software.amazon.awssdk.services.dynamodb.model.GlobalSecondaryIndexUpdate; import software.amazon.awssdk.services.dynamodb.model.UpdateGlobalSecondaryIndexAction; import software.amazon.awssdk.services.dynamodb.model.UpdateTableRequest; import software.amazon.awssdk.services.dynamodb.model.WarmThroughput; public static WarmThroughput buildWarmThroughput(final Long readUnitsPerSecond, final Long writeUnitsPerSecond) { return WarmThroughput.builder() .readUnitsPerSecond(readUnitsPerSecond) .writeUnitsPerSecond(writeUnitsPerSecond) .build(); } public static void updateDynamoDBTable(DynamoDbClient ddb, String tableName, Long tableReadUnitsPerSecond, Long tableWriteUnitsPerSecond, String globalSecondaryIndexName, Long globalSecondaryIndexReadUnitsPerSecond, Long globalSecondaryIndexWriteUnitsPerSecond) { final WarmThroughput tableWarmThroughput = buildWarmThroughput(tableReadUnitsPerSecond, tableWriteUnitsPerSecond); final WarmThroughput gsiWarmThroughput = buildWarmThroughput(globalSecondaryIndexReadUnitsPerSecond, globalSecondaryIndexWriteUnitsPerSecond); final GlobalSecondaryIndexUpdate globalSecondaryIndexUpdate = GlobalSecondaryIndexUpdate.builder() .update(UpdateGlobalSecondaryIndexAction.builder() .indexName(globalSecondaryIndexName) .warmThroughput(gsiWarmThroughput) .build() ).build(); final UpdateTableRequest request = UpdateTableRequest.builder() .tableName(tableName) .globalSecondaryIndexUpdates(globalSecondaryIndexUpdate) .warmThroughput(tableWarmThroughput) .build(); try { ddb.updateTable(request); } catch (DynamoDbException e) { System.err.println(e.getMessage()); System.exit(1); } System.out.println("Done!"); }
  • API の詳細については、「AWS SDK for Java 2.x API リファレンス」の「UpdateTable」を参照してください。

JavaScript
SDK for JavaScript (v3)
import { DynamoDBClient, UpdateTableCommand } from "@aws-sdk/client-dynamodb"; async function updateDynamoDBTableWarmThroughput( tableName, tableReadUnits, tableWriteUnits, gsiName, gsiReadUnits, gsiWriteUnits, region = "us-east-1" ) { try { const ddbClient = new DynamoDBClient({ region: region }); // Construct the update table request const updateTableRequest = { TableName: tableName, GlobalSecondaryIndexUpdates: [ { Update: { IndexName: gsiName, WarmThroughput: { ReadUnitsPerSecond: gsiReadUnits, WriteUnitsPerSecond: gsiWriteUnits, }, }, }, ], WarmThroughput: { ReadUnitsPerSecond: tableReadUnits, WriteUnitsPerSecond: tableWriteUnits, }, }; const command = new UpdateTableCommand(updateTableRequest); const response = await ddbClient.send(command); console.log(`Table updated successfully! Response: ${response}`); } catch (error) { console.error(`Error updating table: ${error}`); throw error; } }
  • API の詳細については、「AWS SDK for JavaScript API リファレンス」の「UpdateTable」を参照してください。

Python
SDK for Python (Boto3)
from boto3 import resource from botocore.exceptions import ClientError def update_dynamodb_table_warm_throughput(table_name, table_read_units, table_write_units, gsi_name, gsi_read_units, gsi_write_units, region_name="us-east-1"): """ Updates the warm throughput of a DynamoDB table and a global secondary index. :param table_name: The name of the table to update. :param table_read_units: The new read units per second for the table's warm throughput. :param table_write_units: The new write units per second for the table's warm throughput. :param gsi_name: The name of the global secondary index to update. :param gsi_read_units: The new read units per second for the GSI's warm throughput. :param gsi_write_units: The new write units per second for the GSI's warm throughput. :param region_name: The AWS Region name to target. defaults to us-east-1 """ try: ddb = resource('dynamodb', region_name) # Update the table's warm throughput table_warm_throughput = { "ReadUnitsPerSecond": table_read_units, "WriteUnitsPerSecond": table_write_units } # Update the global secondary index's warm throughput gsi_warm_throughput = { "ReadUnitsPerSecond": gsi_read_units, "WriteUnitsPerSecond": gsi_write_units } # Construct the global secondary index update global_secondary_index_update = [ { "Update": { "IndexName": gsi_name, "WarmThroughput": gsi_warm_throughput } } ] # Construct the update table request update_table_request = { "TableName": table_name, "GlobalSecondaryIndexUpdates": global_secondary_index_update, "WarmThroughput": table_warm_throughput } # Update the table ddb.update_table(**update_table_request) print("Table updated successfully!") except ClientError as e: print(f"Error updating table: {e}") raise e
  • API の詳細については、『AWS SDK for Python (Boto3) API リファレンス』の「UpdateTable」を参照してください。

SDK for Java 2.x

既存の DynamoDB テーブルのウォームスループット設定を更新します。

import software.amazon.awssdk.services.dynamodb.DynamoDbClient; import software.amazon.awssdk.services.dynamodb.model.DynamoDbException; import software.amazon.awssdk.services.dynamodb.model.GlobalSecondaryIndexUpdate; import software.amazon.awssdk.services.dynamodb.model.UpdateGlobalSecondaryIndexAction; import software.amazon.awssdk.services.dynamodb.model.UpdateTableRequest; import software.amazon.awssdk.services.dynamodb.model.WarmThroughput; public static WarmThroughput buildWarmThroughput(final Long readUnitsPerSecond, final Long writeUnitsPerSecond) { return WarmThroughput.builder() .readUnitsPerSecond(readUnitsPerSecond) .writeUnitsPerSecond(writeUnitsPerSecond) .build(); } public static void updateDynamoDBTable(DynamoDbClient ddb, String tableName, Long tableReadUnitsPerSecond, Long tableWriteUnitsPerSecond, String globalSecondaryIndexName, Long globalSecondaryIndexReadUnitsPerSecond, Long globalSecondaryIndexWriteUnitsPerSecond) { final WarmThroughput tableWarmThroughput = buildWarmThroughput(tableReadUnitsPerSecond, tableWriteUnitsPerSecond); final WarmThroughput gsiWarmThroughput = buildWarmThroughput(globalSecondaryIndexReadUnitsPerSecond, globalSecondaryIndexWriteUnitsPerSecond); final GlobalSecondaryIndexUpdate globalSecondaryIndexUpdate = GlobalSecondaryIndexUpdate.builder() .update(UpdateGlobalSecondaryIndexAction.builder() .indexName(globalSecondaryIndexName) .warmThroughput(gsiWarmThroughput) .build() ).build(); final UpdateTableRequest request = UpdateTableRequest.builder() .tableName(tableName) .globalSecondaryIndexUpdates(globalSecondaryIndexUpdate) .warmThroughput(tableWarmThroughput) .build(); try { ddb.updateTable(request); } catch (DynamoDbException e) { System.err.println(e.getMessage()); System.exit(1); } System.out.println("Done!"); }
  • API の詳細については、「AWS SDK for Java 2.x API リファレンス」の「UpdateTable」を参照してください。

AWS SDK デベロッパーガイドとコード例の詳細なリストについては、「AWS SDK で DynamoDB を使用する」を参照してください。このトピックには、使用開始方法に関する情報と、以前の SDK バージョンの詳細も含まれています。

プライバシーサイト規約Cookie の設定
© 2025, Amazon Web Services, Inc. or its affiliates.All rights reserved.