AWS autoscaling starts not ready instances because of userdata script
<p>I have an autoscaling that works great, with a launchconfiguration where i defined a userdata script that is executed on a new instance launch.</p>
<p>The userscript updates basecode and generate cache, this takes some seconds. But as soon as the instance is &quot;created&quot; (and not &quot;ready&quot;), the autoscaling adds it to the load balancer.</p>
<p>It's a problem because while the userdata script is executed, the instance does not answer with a good response (basically, 500 errors are throw).</p>
<p>I would like to avoid that, of course I saw this documentation : <a href="http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/InstallingAdd" rel="nofollow noreferrer">http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/InstallingAdd</a></p>
<blockquote>
<p>As with a standalone EC2 instance, you have the option of configuring instances launched into an Auto Scaling group using user data. For example, you can specify a configuration script using the User data field in the AWS Management Console, or the --userdata parameter in the AWS CLI.</p>
<p>If you have software that can't be installed using a configuration script, or if you need to modify software manually before Auto Scaling adds the instance to the group, add a lifecycle hook to your Auto Scaling group that notifies you when the Auto Scaling group launches an instance. This hook keeps the instance in the Pending:Wait state while you install and configure the additional software.</p>
</blockquote>
<p>Looks like i'm not in this case. Also, modify the pending hook on the userdata script is complicated. There must be a simple solution to fix my problem.</p>
<p>Thank you for your help !</p>