I've recently moved an application to Elastic Beanstalk. I'm currently in the process of setting up log files to be archived. One of the business requirements is x days of log retention, which is pretty sensible of course. Since log files are stored on the instance, and the instance data is not persisted when terminating/re-creating the instance, the logs need to be stored elsewhere.
Elastic Beanstalk offers the option of "S3 log storage", which seems to upload rotated log files to S3, which would cover most of my needs. The one exception would be when an instance is terminated/re-created: how can I easily assure that before termination, the not-yet-rotated log files are uploaded to S3?