微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何在 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 举报,一经查实,本站将立刻删除。