将输出过滤为变量

时间:2019-06-27 18:29:25

标签: boto3 aws-eks

我正在编写一个需要自定义等待的CloudFormation模板。为了使其正常工作,我需要运行第一个任务的更新ID。

我得到的回复是{'ResponseMetadata': {'RequestId': 'f95a182a-9908-11e9-a8b8-2967c8573c31', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Thu, 27 Jun 2019 18:25:44 GMT', 'content-type': 'application/json', 'content-length': '313', 'connection': 'keep-alive', 'x-amzn-requestid': 'f95a182a-9908-11e9-a8b8-2967c8573c31', 'x-amz-apigw-id': 'b86GJE-lCYcF1qw=', 'x-amzn-trace-id': 'Root=1-5d150a27-cc9c3290fba93939d77af990'}, 'RetryAttempts': 0}, 'update': {'id': 'cf86b57c-c1a9-4a72-8828-01dd786e171f', 'status': 'InProgress', 'type': 'LoggingUpdate', 'params': [{'type': 'ClusterLogging', 'value': '{"clusterLogging":[{"types":["api","audit","authenticator","controllerManager","scheduler"],"enabled":true}]}'}], 'createdAt': datetime.datetime(2019, 6, 27, 13, 25, 43, 853000, tzinfo=tzlocal()), 'errors': []}}

我要过滤的两个关键属性是id和status。我已经尝试过update.id,updateid,updateID和[update] [1] [id],它们全都给了我一个关键错误。

1 个答案:

答案 0 :(得分:1)

您可以使用

response['update']['id']
response['update']['status']