我有一个包含多个键值对的基本JSON文件。我想从JSON解析一个值,并运行AWS命令来创建SSM参数存储
如何添加循环,以便我的cmd将从JSON获取每个名称和每个值,并创建每个参数存储
参数JSON:
{
"Name" : "Account Summary",
"Value" : "/some/values/to/be/there"
"Name" : "Account Investment"
"Value" : "/some/other/values/here"
}
Python脚本:
with open("parameters.json") as f:
baselist = json.load(f)
for key, value in baselist.items():
aws ssm put-parameter --name "" --type "String" --value ""
这是您要查找的JSON的有效格式
你的循环看起来像这样:
输出如下所示:
您应该使用AWS提供的boto3Python SDK来实现这类功能。这是访问脚本上AWS资源的推荐方法
这是同一
put-parameter
文档中的示例代码片段:正如您所看到的,它有更多的特性,您可以更有效地检查响应的合理性,因为这将抛出可以在脚本上检查的实际Python异常
相关问题 更多 >
编程相关推荐