I have an Autoscaling group, with EC2 instances that are manage via lifecycle hooks.
One thing the lifecycle hooks do, is some cleanup on the EC2 Instances ensuring all processes are stopped properly. For debugging purposes, this cleanup is logged to log files that are send to cloudwatch logs via cloudwatch log agent.
The problem is, that when the lifecycle hook completes, the instance is terminated and the cloudwatch agent might not yet have uploaded all the logs.
Is there a way to tell cloudwatch agent to send logs now! Or wait for it to update the logs?