AWS – Keeping User’s Filesystem Persistent Across EC2 Spot Instances

amazon ec2amazon-web-servicesautofsautomationautomount

I noticed that, after a new Amazon AWS EC2 spot instance is auto-launched (I have that option turned on), the state of filesystem is not current (represent the last state before previous spot instance is auto-shutdown due to current price going over my set limit). I guess the initial state of newly launched spot instance's filesystem is based on the AMI that I use to auto-launch the spot instance. I have the following questions:

Is it possible, and, if yes, what can be done, to automate saving the state of filesystem before the auto-shutdown and restoring it during the auto-launch of a new spot instance? If it's not possible, at least, is it possible to automate downloading and running shell scripts that would bring the system to a desired state (auto-update the system via apt-get, get the latest source code via git, etc.)?

Thank you!

Best Answer

You can launch your spot instance with a persistent EBS root volume (or attach a separate EBS volume post-boot). The EBS volume will remain after your spot instance terminates.

See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts-spot-instances-applications-ebs.html