We are using AWS Cloud Trail to retrieve data (cloud trail events). We have used the gem 'aws-sdk-cloudtrail' (version 1.0). As per Cloud Trail we are able to retrieve maximum 50 results (latest once). To fetch the previous (older once ) results we use 'next-token' received in the previous response. We perform this until we get an empty 'next-token'. When we receive an empty token it means all the cloud trail data has been retrieved.
For example: Suppose Cloud Trail has 100 events logged in: In the first api call we received the latest 50 results along with the token to retrieve next 50 (older 50). In the second api call we receive the remaining 50 results (older results) along with next token as nil. It means there are no more results to be fetched.
In our case we are saving all the results received from the trail in our local database.We repeat this periodically. When doing it for the second time (repeating above explained process) we again receive few newer and few older results. We again repeat the API call until we get 'next-token' as nil. This results in receiving redundant data which was already stored in the database when the first cycle executed. Is there any way to get only the newly logged cloud trail events second cycle on-wards.