Assuming you are using linux, you can create a pre-baked AMI that you use in your Launch Config attached to your Auto Scaling Group.
In the AMI you can put a script under /etc/init.d
say /etc/init.d/servicesdown
. This script would execute anything that you need to shutdown which would be scripts under /usr/share/services
for example.
Here's kind like the gist:
It would always get executed when doing a graceful shutdown.
Then say on Ubuntu/Debian you would do something like this to add it to your shutdown sequence:
/usr/sbin/update-rc.d servicesdown stop 25 0 1 6 .
On CentOS/RedHat you can use the chkconfig
command to add it to the right shutdown runlevel.