json - 如何将 json 存储到/从 aws 参数存储

标签 json amazon-web-services parameters store livy

我使用 Livy REST API 提交 Spark 应用。

{
  “file”: <application-jar>,
  “className”: “<main-class>”,
  “args”: my_args,
  “conf”: my_conf
}

my_args = [args1, args2, ...]
my_conf = {'foo1': 'bar1', 'foo2': 'bar2'...}

我希望 my_conf(json secret )存储在 AWS SSM 参数存储中,并在我使用 Livy 的 python 脚本提交 spark 应用程序时从参数存储中使用它。 如何存储和获取(在 python 中获取相同的 json)my_conf 到/从参数存储?

最佳答案

import json
import boto3

my_conf = {'foo1': 'bar1', 'foo2': 'bar2'}
boto3.client('ssm').put_parameter(Name='MyParameter', Value=json.dumps(my_conf), Type='String')
my_conf = json.loads(boto3.client('ssm').get_parameter(Name='MyParameter'))

...假设您已经设置了允许您进行这些调用的适当权限。

关于json - 如何将 json 存储到/从 aws 参数存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60329379/

相关文章:

amazon-web-services - 自定义授权者的 AWS API 网关 403 错误

java - 从自定义 URL 处理程序获取参数

objective-c - NSJSONSerialization.JSONObjectWithData 浮点转换/舍入错误?

c - 在 C 程序中使用 JSON PUT

python - 我如何通过使用 python 传递参数来调用 AWS lambda 函数?

amazon-web-services - AWS CloudFormation 键不接受特殊字符

scala - 在 Scala 中,如何传递具有多个参数列表的函数作为参数?

具有多个变量输入的 R 自定义 data.table 函数

ios - 复合键问题 Realm Swift

c# - 如何使用继承/多态性将 JSON 字符串解析为 C# 对象?