【问题标题】:unable to create DynamoDB table from aws CLI无法从 aws CLI 创建 DynamoDB 表
【发布时间】:2021-04-21 03:09:11
【问题描述】:

我对 aws 很陌生。我试图通过运行以下命令来创建数据库表: ``

aws dynamodb create-table --table-name pizza-order --attribute-definitions AttributeName=orderId, AttributeType=S --key-schema AttributeName=orderId,keyType=HASH --provisioned-throughput ReadCapacityUnit=1,WriteCapacityUnit=1 --region us-east-2  --query TableDescription.TableArn --output text
``

但我收到这样的错误: 错误解析参数'--attribute-definitions':预期:'',接收:''输入: AttributeName=orderId,

【问题讨论】:

  • AttributeName=orderId, AttributeType=S, 你能把orderId and AttributeType and its KeyType,and ReadCapacityUnits same goes for WriteCapacityUnits 之间的空格去掉吗,你为什么要使用--query TableDescription.TableArn --output text 你想用``查询选项实现什么

标签: amazon-web-services amazon-dynamodb aws-cli


【解决方案1】:

该命令适用于以下修改:

  • 删除 orderId 后的空格,
  • KeyType 大写正确
  • ReadCapacityUnits 和 WriteCapacityUnits 正确复数。

这是供您参考的工作命令:

aws dynamodb create-table --table-name pizza-order --attribute-definitions AttributeName=orderId,AttributeType=S --key-schema AttributeName=orderId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --region us-east-2 --query TableDescription.TableArn --output text

【讨论】:

  • 在 dong 之后给出以下错误。你能告诉我该怎么做吗!? ? 调用 CreateTable 操作时发生错误 (AccessDeniedException):用户:arn:aws:iam::676374644948:user/suraiya_moon126 无权执行:dynamodb:CreateTable on resource:arn:aws:dynamodb:us-east-2 :676374644948:table/pizza-order
  • 您需要通过转到 iam 中的用户 -> 在权限下添加权限 -> 直接附加现有策略来将策略附加到您的 Iam 用户。搜索 dynamodb 完全访问权限并添加它:)
【解决方案2】:
aws dynamodb create-table --table-name pizza-order --attribute-definitions AttributeName=orderId,AttributeType=S --key-schema AttributeName=orderId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --region us-east-2 --query TableDescription.TableArn --output text

参考文档 https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/getting-started-step-1.html

要验证 DynamoDB 是否已完成创建 Music 表,请使用 describe-table 命令。

 aws dynamodb describe-table --table-name pizza-order | grep TableStatus

此命令返回以下结果。当 DynamoDB 完成创建表时,TableStatus 字段的值设置为 ACTIVE。

"TableStatus": "ACTIVE",

注意:- 每当您遇到困难或想了解命令的详细信息时,最好检查 aws cli 文档以获取特定 API for create table

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-21
    • 1970-01-01
    • 1970-01-01
    • 2019-03-23
    相关资源
    最近更新 更多