I'm setting up an Ubuntu instance on Amazon EC2 and I'm trying to configure it so that, at startup, it automatically attaches an EBS volume and takes an elastic IP address and, at shutdown, it automatically releases those resources.
I found various init scripts that do what I want, but I'd really like to use an upstart job, so that I can automatically install it through cloud-init.
I understand from this exchange that the event I want to monitor to start my job is, for lucid and maverick
start on stopped cloud-run-user-script
and for natty
start on stopped cloud-final
Is this really accurate? Also, what is the correct event to monitor to stop my job (including unmounting and detaching the EBS volume and releasing the elastic IP)?
Best Answer
The events are correct if you specifically need to run when cloud-init has finished. You probably will want your script to be done with the keyword
task
, so that the bits that depend on cloud-init are blocked until your script finishes.For shutdown
Will run something as the normal system shutdown is happening.
Note that there's a wealth of information about these things in the upstart cookbook:
http://upstart.ubuntu.com/cookbook/