나는 모든 알람 속성과 그 값의 목록을 만들기 위해 노력하고 BOTO 사전의 목록을 만들 수 있습니다. 이것이 내가하려는 일이다.AWS
import json
import boto.ec2.cloudwatch
conn = boto.ec2.cloudwatch.connect_to_region('ap-southeast-1')
alarms = conn.describe_alarms()
single_dict = {}
whitelist = ["name", "metric", "namespace", "statistic", "comparison", "threshold", "period", "evaluation_periods", "unit", "description", "dimensions", "alarm_actions", "insufficient_data_actions", "ok_actions"]
x = []
for alarm in alarms:
for attr in whitelist:
single_dict[attr] = getattr(alarm, attr)
print single_dict
x.append(single_dict)
print x
이 해결책은 효과가 없습니다. 항상 동일한 값을 포함하는 사전 목록을 얻습니다. 하지만 예를 들어 single_dict를 인쇄하려고하면 각 반복마다 올바른 값을 얻습니다. 왜 그럴까요?
이있어, 빠른 답장을 보내 주셔서 감사합니다 :) – hjelpmig