如何在 MWAA 气流中导入气流变量

问题描述

我无法通过 Boto3 和 aws_mwaa 将新的气流变量从 json 文件导入到我的 MWAA 环境中。 aws_mwaa/cli 的响应代码是 400。不过,我能够获取现有变量的值。有什么帮助吗?

import requests
import boto3
import base64


def main():
    env = "<MWAA-ENV-NAME>"
    client = boto3.client('mwaa')
    response = client.create_cli_token(Name=env)
    auth_token=response.get('CliToken')
    hed = {'Content-Type': 'text/plain','Authorization': 'Bearer ' + auth_token}
    data = "variables -i <local JSON File Path>"
    url = 'https://{web_server}/aws_mwaa/cli'.format(web_server=response.get('WebServerHostname'))
    r = requests.post(url,data=data,headers=hed)
    print_output(r)


def print_output(r):
    output = base64.b64decode(r.json()['stdout']).decode('utf8')
    print(output)


if __name__ == '__main__':
    main()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)