Everyday I launch a lot of EC2 instances as part of a controlled process:

I also wind up running a lot of ad-hoc instances for quick experiments. This required a frustrating multi-step dance:

  1. ec2-run-instances
  2. highlight and copy the Instance ID
  3. wait long enough that networking is provisioned
  4. ec2-describe-instances with the pasted id
  5. highlight and copy the Public DNS attribute
  6. wait long enough that sshd will be available before the connection times out
  7. ssh -oForwardAgent=yes -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -i ~/.ec2/keypair.pem with the pasted hostname

Last week I got to the breaking point during one of these cycles and hacked together a script to launch and log into these one-off instances. The helpful tcp_test_ssh and wait_for_sshd methods are grabbed mostly verbatim from the previously mentioned knife-ec2 plugin.