与下面的内容创建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操作系统)的文件路径,并执行以下命令
在本地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上)中的数据。
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
我得到下面的错误:CreateTable操作:'访问'不是一个有效的键=值对(缺少等号),我缺少什么? –
更新答案,提供所有必需的详细信息。如果您在我的回答中提到了详细信息,但仍然出现错误,那么问题可能出在您的访问密钥上。 – notionquest
感谢@notionquest你可以给我一个想法,使用一个json文件创建多个表。 –