使用AWS CLI创建dynamodb表 [英] create dynamodb table using AWS CLI

查看:203
本文介绍了使用AWS CLI创建dynamodb表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying below command after 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

输出:没什么

请提出如何使用AWS CLI创建dyanmodb表的建议.

Please give suggestion how to create dyanmodb table using AWS CLI.

推荐答案

  1. 使用以下内容创建JSON文件 create-table-movies.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
    }
}

  • 浏览至DOS命令提示符下的文件路径(假设使用Windows操作系统)并执行以下命令

  • Browse to the file path on DOS command prompt (assuming Windows OS) and execute the below command

    在本地DynamoDB上创建表:-

        aws dynamodb create-table --cli-input-json file://create-table-movies.json --endpoint-url http://localhost:8000
    

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

    aws dynamodb create-table --cli-input-json file://create-table-movies.json --region us-west-2
    

    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]:
    

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

    Once you execute the above command, it updates the data on your profile (on windows).

    C:\Users\<username>\.aws\
    

    检查以下文件:-

    config   - should have the region name
    credentials  - should have access key and secret key
    

    凭据示例:-

    [default]
    aws_access_key_id = aaaadffewe
    aws_secret_access_key = t45435egfdg456retgfg
    

    配置文件示例:-

    [default]
    region = us-east-1
    

    这篇关于使用AWS CLI创建dynamodb表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆