如何将大量ENV变量添加到弹性豆茎环境中?使用boto3



我使用boto3更新环境变量,但每次update_environment((调用都会强制环境完全"更新",但我不知道如何同时执行多个值。

single_query = { 'Namespace': 'aws:elasticbeanstalk:application:environment', 
"OptionName": "{}", 
"Value":"{}}"}
stuff = [] 
for var in env_json.items():
stuff.append(single_query.format(var[0], var[1]))

所以env_json是我想添加到环境中的变量的字典

这并不是我想要的清单。我如何才能得到一个单独json对象的列表,这些对象将被放入update_environment((的OptionSettings参数中?

我知道这是一个老问题,但当我搜索时,谷歌把我链接到了这里。以防其他人在搜索时偶然发现这个问题。以下是我的做法。

option_settings = []
for env_variable, env_value in env_variable_dict.items():
opt = {
'Namespace': 'aws:elasticbeanstalk:application:environment',
'OptionName': env_variable,
'Value': env_value
}
option_settings.append(opt)
response = client.update_environment(
ApplicationName='appname',
EnvironmentName='env-name',
OptionSettings=option_settings
)

最新更新