When an instance boots quickly on Amazon EC2 the init code can occasionally try to use the network before the network is working.
This may not happen on most boots, but it is definitely worth adding in some code to check for the network before attempting to do critical tasks like:
- download ssh public key
- download user-data
Here is a sample of the script I use to download ssh credentials on the existing Ubuntu EC2 images:
Until this check was added, people experienced random failures where an AMI would boot ok, but they were unable to ssh in because the ssh credentials download had failed.
Many non-Ubuntu AMIs do not experience this problem because they boot so slowly :)
When an instance boots quickly on Amazon EC2 the init code can occasionally try to use the network before the network is working.
This may not happen on most boots, but it is definitely worth adding in some code to check for the network before attempting to do critical tasks like:
- download ssh public key
- download user-data
Here is a sample of the script I use to download ssh credentials on the existing Ubuntu EC2 images:
http:// ec2ubuntu. googlecode. com/svn/ trunk/etc/ init.d/ ec2-get- credentials
Note the following code which waits until the network is working before it continues:
perl -MIO::Socket::INET -e ' :INET(" 169.254. 169.254: 80")){print" Waiting for network...\n";sleep 1}
until(new IO::Socket:
' | $logger
Until this check was added, people experienced random failures where an AMI would boot ok, but they were unable to ssh in because the ssh credentials download had failed.
Many non-Ubuntu AMIs do not experience this problem because they boot so slowly :)