title: Invoke a script on EC2 termination
body: <p>I have to take certain actions during AWS autoscaling scale-in event.The ec2 instance should be able to save some logs and reports to S3 bucket. This can take anywhere between 5 to 15 mins.</p>
  
  <p>I already have a script that gets called on termination:</p>
  
  <p><code>ln -s /etc/ec2-termination /etc/rc0.d/S01ec2-termination</code></p>
  
  <p>However the script ends abruptly within 5 mins. I am looking at leveraging AWS LifeCycle hooks to extend the EC2 lifetime.
  The documentation is not clear on invoking a script in a way similar to user-data script.</p>
  
  <p>There are ways of using AWS lambda or SNS to receive notification. This can be potentially used to inform the ec2.</p>
  
  <p>But, I would like to know if there is a simpler solution to this problem. Is there a way to register a script with Lifecycle hooks that gets called on a scale-in event.</p>