LoginSignup
0
0

More than 3 years have passed since last update.

DynamoDB CLIから使うときに知りたくなるコマンド

Last updated at Posted at 2019-09-27

環境

$ aws --version
aws-cli/1.16.155 Python/2.7.16 Darwin/19.0.0 botocore/1.12.145

テーブル一覧を表示

$ aws dynamodb list-tables
{
    "TableNames": [
        "Forum", 
        "Movies"
    ]
}

テーブル情報を知る

$ aws dynamodb describe-table --table-name Movies
{
    "Table": {
        "TableArn": "arn:aws:dynamodb:ap-northeast-1:470824059488:table/Movies", 
        "AttributeDefinitions": [
            {
                "AttributeName": "title", 
                "AttributeType": "S"
            }, 
            {
                "AttributeName": "year", 
                "AttributeType": "N"
            }
        ], 
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0, 
            "WriteCapacityUnits": 10, 
            "ReadCapacityUnits": 10
        }, 
        "TableSizeBytes": 0, 
        "TableName": "Movies", 
        "TableStatus": "ACTIVE", 
        "TableId": "f487b461-41df-41da-aaed-557a60291da8", 
        "KeySchema": [
            {
                "KeyType": "HASH", 
                "AttributeName": "year"
            }, 
            {
                "KeyType": "RANGE", 
                "AttributeName": "title"
            }
        ], 
        "ItemCount": 0, 
        "CreationDateTime": 1569596682.931
    }
}

データを挿入する

$ aws dynamodb put-item --table-name Movies --item '{"title":{"S":"Titanic"},"year":{"N":"1997"}}'
$ aws dynamodb put-item --table-name Movies --item '{"title":{"S":"The Godfather"},"year":{"N":"1972"}}'

テーブルの全てのデータを表示

$ aws dynamodb scan --table-name=Movies
{
    "Count": 2, 
    "Items": [
        {
            "year": {
                "N": "1997"
            }, 
            "title": {
                "S": "Titanic"
            }
        }, 
        {
            "year": {
                "N": "1972"
            }, 
            "title": {
                "S": "The Godfather"
            }
        }
    ], 
    "ScannedCount": 2, 
    "ConsumedCapacity": null
}

参考

aws cli で DynamoDB を使う - Qiita
DynamoDBをlocal環境で動かしてみる - Qiita

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