我想将一些dynamodb表(仅架构)复制到我的本地环境中以进行测试.首先我尝试过:
aws dynamodb describe-table --table-name Foo > FooTable.json
但很明显,输出模式不符合create-table命令的输入模式:
aws dynamodb create-table --cli-input-json file://FooTable.json --endpoint=http://localhost:8000
我想避免的是生成几十个骷髅aws dynamodb create-table --generate-cli-skeleton并手动填充它们:/
有没有办法以一种对娱乐"有用"的格式获取表模式?我觉得令人难以置信的是,通过网络图形界面或标准aws命令行没有直接的方式 - 在听到他们的服务"好"之后.
我在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表的建议.
我正在使用需要在AWS CloudFormation YAML模板中读取的PyYAML库编写自定义Python应用程序。
我知道模板是有效的CloudFormation模板,因为我使用validate-template测试了它们:
? aws cloudformation validate-template --template-body file://cloudformation.yml
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用PyYAML库读取它们时,出现如下错误:
yaml.scanner.ScannerError:此处不允许映射值
和
无法确定标签“!Sub”的构造函数
和别的。
作为示例,我尝试以下AWS示例模板:
? curl -s \
https://raw.githubusercontent.com/awslabs/aws-cloudformation-templates/master/aws/services/CloudFormation/FindInMap_Inside_Sub.yaml \
-o FindInMap_Inside_Sub.yaml
Run Code Online (Sandbox Code Playgroud)
然后:
? python
Python 2.7.15 (default, Nov 27 2018, 21:40:55)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.load(open('FindInMap_Inside_Sub.yaml'))
Run Code Online (Sandbox Code Playgroud)
这导致:
yaml.constructor.ConstructorError: could not determine a constructor for the tag '!FindInMap'
in "FindInMap_Inside_Sub.yaml", line 89, column 45
Run Code Online (Sandbox Code Playgroud)
如何使用PyYAML之类的库解析CloudFormation YAML文件?