我无法通过 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()