Help us understand the problem. What is going on with this article?

[JAWS-UG CLI] DynamoDB:#3 テーブルの更新 (プロビジョンドスループットの変更)

More than 5 years have passed since last update.

http://jawsug-cli.doorkeeper.jp/events/18571 でのハンズオン資料です。

AWS CLIを利用して、DynamoDBのテーブルを更新(プロビジョンドスループットの変更)してみます。

  • describe-table
  • update-table

前提条件

DynamoDBへの権限

  • DynamoDBに対してフル権限があること。

AWS CLIのバージョン

以下のバージョンで動作確認済

  • AWS CLI 1.7.7

0. 事前作業

0.1. 変数の確認

変数の確認
cat << ETX

AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
DYNAMO_TABLE_NAME:  ${DYNAMO_TABLE_NAME}

ETX

0.2. DynamoDBテーブル名の指定

DYNAMO_TABLE_NAMEが空か、想定と異なる場合は指定しなおします。

コマンド(例)
DYNAMO_TABLE_NAME='ProductCatalog'

1. 現状の確認

コマンド
aws dynamodb describe-table --table-name ${DYNAMO_TABLE_NAME}
結果(例)
      {
        "Table": {
          "AttributeDefinitions": [
              {
                  "AttributeName": "Id",
                  "AttributeType": "N"
              }
          ],
          "ProvisionedThroughput": {
              "NumberOfDecreasesToday": 0,
              "WriteCapacityUnits": 5,
              "ReadCapacityUnits": 10
          },
          "TableSizeBytes": 0,
          "TableName": "ProductCatalog",
          "TableStatus": "ACTIVE",
          "KeySchema": [
              {
                  "KeyType": "HASH",
                  "AttributeName": "Id"
              }
          ],
          "ItemCount": 0,
          "CreationDateTime": 1423981762.455
        }
      }

2. 変更

コマンド
DYNAMO_READ_UNIT='1'
DYNAMO_WRITE_UNIT='1'
コマンド
DYNAMO_PROV_THPUT="ReadCapacityUnits=${DYNAMO_READ_UNIT},WriteCapacityUnits=${DYNAMO_WRITE_UNIT}"
変数の確認
cat << ETX

        DYNAMO_TABLE_NAME: ${DYNAMO_TABLE_NAME}
        DYNAMO_PROV_THPUT: ${DYNAMO_PROV_THPUT}

ETX
コマンド
aws dynamodb update-table \
        --table-name ${DYNAMO_TABLE_NAME} \
        --provisioned-throughput ${DYNAMO_PROV_THPUT}
結果(例)
      {
        "TableDescription": {
          "AttributeDefinitions": [
              {
                  "AttributeName": "Id",
                  "AttributeType": "N"
              }
          ],
          "ProvisionedThroughput": {
              "NumberOfDecreasesToday": 0,
              "WriteCapacityUnits": 5,
              "ReadCapacityUnits": 10,
              "LastDecreaseDateTime": 1423982698.049
          },
          "TableSizeBytes": 0,
          "TableName": "ProductCatalog",
          "TableStatus": "UPDATING",
          "KeySchema": [
              {
                  "KeyType": "HASH",
                  "AttributeName": "Id"
              }
          ],
          "ItemCount": 0,
          "CreationDateTime": 1423966555.28
        }
      }

3. 確認

3.1. 更新完了の確認

コマンド
aws dynamodb describe-table \
        --table-name ${DYNAMO_TABLE_NAME} \
        --query 'Table.TableStatus' \
        --output text
結果
      ACTIVE

3.2. 更新完了の確認

コマンド
aws dynamodb describe-table --table-name ${DYNAMO_TABLE_NAME}
結果(例)
      {
        "Table": {
          "AttributeDefinitions": [
              {
                  "AttributeName": "Id",
                  "AttributeType": "N"
              }
          ],
          "ProvisionedThroughput": {
              "NumberOfDecreasesToday": 1,
              "WriteCapacityUnits": 1,
              "ReadCapacityUnits": 1,
              "LastDecreaseDateTime": 1423982764.696
          },
          "TableSizeBytes": 0,
          "TableName": "ProductCatalog",
          "TableStatus": "ACTIVE",
          "KeySchema": [
              {
                  "KeyType": "HASH",
                  "AttributeName": "Id"
              }
          ],
          "ItemCount": 0,
          "CreationDateTime": 1423966555.28
        }
      }

完了

最後に、テーブルを削除してみましょう。
http://qiita.com/tcsh/items/11f01f189550be8b826e

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away