I am trying to get events like (runinstances,createtags & terminateinstances) from cloudtrail for a instance id through boto3, below is my code
import boto3
cloudtrail = boto3.client('cloudtrail')
instance_id = 'i-0002e660b987688'
starttime = '2020-04-01'
endtime = '2020-04-03'
try:
response = cloudtrail.lookup_events(
LookupAttributes=[
{
'AttributeKey': 'ResourceName',
'AttributeValue': instance_id
},
],
StartTime=starttime,
EndTime=endtime,
MaxResults=50
)
except Exception as e:
print(e)
raise(e)
print(response)
I am not getting any events , where as from AWS console I can see all those events for the time period specified above.
{u'Events': [], 'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': '658e4873-b0d1-453c', 'HTTPHeaders': {'x-amzn-requestid': '658e4873-b0d1-453', 'date': 'Fri, 03 Apr 2020 03:53:57 GMT', 'content-length': '13', 'content-type': 'application/x-amz-json-1.1'}}}