I'm writing a script which shuts down EC2 instances remotely using ec2-terminate-instances. I would like to perform orderly shutdowns (similar to the ones triggered by Linux 'shutdown' command) instead of simply turning the power off. This would give me time to shut down running services and properly unmount an EC2 volume.
Unfortunately, I can't log into these instances using SSH without doing a lot of extra work. Is there an easy way to trigger a remote, orderly shutdown? Or will I need to write some sort of control daemon that lives on the server, and which I can poke when I want the server to shut down?