lookup_events使用boto3不返回事件详细信息
问题描述:
我使用下面的代码,但没有得到所需的事件详细信息。我确认事件ID是正确的,并检查从aws UI返回的详细信息lookup_events使用boto3不返回事件详细信息
我也试过在事件ID之前和之后没有单引号,但没有返回细节。
client = boto3.client('cloudtrail',region_name='us-east-1')
response = client.lookup_events(
LookupAttributes=[
{
'AttributeKey': 'EventId',
'AttributeValue': "'" + str(eventid) + "'"
},
],
MaxResults=1,
)
下面是我收到的回复,事件是空的。
{u'Events': [], 'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': 'ea8888ab-0987-1234-4321-096c31sdfsdf', 'HTTPHeaders': {'x-amzn-requestid': '345551dd-1234-9876-1221-sddweerwer', 'date': 'Sat, 11 Nov 2017 17:08:20 GMT', 'content-length': '13', 'content-type': 'application/x-amz-json-1.1'}}}
答
的属性尝试
LookupAttributes=[
{
'AttributeKey': 'EventId',
'AttributeValue': "{}".format(eventid)
},
]
如果不是这样,也许三重检查eventid
定义?
答
请勿在EventId中加引号。只有在通过Python传递原始值时才需要引号 - 实际值不应包含引号。
'AttributeValue': eventid
此解决方案适合我!谢谢 !! – dip