使用AWS CLI创建dynamodb表

Ano*_*mar 6 amazon-dynamodb aws-cli

我在aws之后尝试下面的命令

--configure command:

aws dynamodb create-table 
--table-name MusicCollection2 
--attribute-definitions

 AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S --

key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE 

--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Run Code Online (Sandbox Code Playgroud)

输出:没什么

请提供有关如何使用AWS CLI创建dyanmodb表的建议.

not*_*est 21

  1. create-table-movies.json使用以下内容创建JSON文件

    {
        "TableName": "MusicCollection2",
        "KeySchema": [
          { "AttributeName": "Artist", "KeyType": "HASH" },
          { "AttributeName": "SongTitle", "KeyType": "RANGE" }
        ],
        "AttributeDefinitions": [
          { "AttributeName": "Artist", "AttributeType": "S" },
          { "AttributeName": "SongTitle", "AttributeType": "S" }
        ],
        "ProvisionedThroughput": {
          "ReadCapacityUnits": 5,
          "WriteCapacityUnits": 5
        }
    }
    
    Run Code Online (Sandbox Code Playgroud)
  2. 在DOS命令提示符下浏览到文件路径(假设是Windows操作系统)并执行以下命令

在本地DynamoDB上创建表: -

    aws dynamodb create-table --cli-input-json file://create-table-movies.json --endpoint-url http://localhost:8000
Run Code Online (Sandbox Code Playgroud)

要在AWS DynamoDB服务上创建表,请提供正确的区域名称.如果您的配置已经完成,它应该可以工作.

aws dynamodb create-table --cli-input-json file://create-table-movies.json --region us-west-2
Run Code Online (Sandbox Code Playgroud)

AWS CLI配置: -

$ aws configure
AWS Access Key ID [None]: accesskey
AWS Secret Access Key [None]: secretkey
Default region name [None]: us-west-2
Default output format [None]:
Run Code Online (Sandbox Code Playgroud)

执行上述命令后,它会更新配置文件中的数据(在Windows上).

C:\Users\<username>\.aws\
Run Code Online (Sandbox Code Playgroud)

检查以下文件: -

config   - should have the region name
credentials  - should have access key and secret key
Run Code Online (Sandbox Code Playgroud)

证书样本: -

[default]
aws_access_key_id = aaaadffewe
aws_secret_access_key = t45435egfdg456retgfg
Run Code Online (Sandbox Code Playgroud)

配置文件示例: -

[default]
region = us-east-1
Run Code Online (Sandbox Code Playgroud)