0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2015-02-16

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

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

  • describe-table
  • update-table

前提条件

DynamoDBへの権限

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

AWS CLIのバージョン

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

  • AWS CLI 1.7.7
  1. 事前作業
    ===========

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
        }
      }
  1. 変更
    =======
コマンド
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
        }
      }
  1. 確認
    =======

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

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?